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

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy