dev.forkhandles.values.value.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of values4k Show documentation
Show all versions of values4k Show documentation
ForkHandles Value-types library
The newest version!
package dev.forkhandles.values
import dev.forkhandles.values.Maskers.public
/**
* Base value interface which enables type-safe primitives, along with Validation.
*/
interface Value {
val value: T
}
abstract class AbstractValue @JvmOverloads constructor(
override val value: T,
private val masking: Masking = public
) : Value {
override fun toString() = masking(value)
override fun hashCode() = value.hashCode()
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false
other as AbstractValue<*>
if (value != other.value) return false
return true
}
}