dev.forkhandles.values.comparable.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
interface ComparableValue :
Value,
Comparable
where
DOMAIN : Value,
PRIMITIVE : Comparable
{
override fun compareTo(other: DOMAIN) = value.compareTo(other.value)
}
abstract class AbstractComparableValue(value: PRIMITIVE) :
AbstractValue(value),
ComparableValue
where
DOMAIN : Value,
PRIMITIVE : Comparable
fun compareByValue(): Comparator
where
PRIMITIVE : Comparable,
DOMAIN : Value
= compareByValue(naturalOrder())
fun compareByValue(order: Comparator): Comparator
where
PRIMITIVE : Comparable,
DOMAIN : Value
= compareBy(comparator = order, selector = { it.value })