All Downloads are FREE. Search and download functionalities are using the official Maven repository.

dev.forkhandles.values.value.kt Maven / Gradle / Ivy

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
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy