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

commonMain.com.dshatz.fuzzykat.ToStringFunction.kt Maven / Gradle / Ivy

The newest version!
package com.dshatz.fuzzykat


/**
 * Transforms an item of type T to a String.
 *
 * @param  The type of the item to transform.
 */
interface ToStringFunction {
    /**
     * Transforms the input item to a string.
     *
     * @param item The item to transform.
     * @return A string to use for comparing the item.
     */
    fun apply(item: T): String

    companion object {

        /**
         * A default ToStringFunction that returns the input string;
         * used by methods that use plain strings in [FuzzySearch].
         */
        val NO_PROCESS: ToStringFunction = object : ToStringFunction {
            override fun apply(item: String): String {
                return item
            }
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy