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

commonMain.com.dshatz.fuzzykat.diffutils.algorithms.RatioAlgorithm.kt Maven / Gradle / Ivy

The newest version!
package com.dshatz.fuzzykat.diffutils.algorithms

import com.dshatz.fuzzykat.Ratio
import com.dshatz.fuzzykat.ToStringFunction
import com.dshatz.fuzzykat.diffutils.ratio.SimpleRatio

abstract class RatioAlgorithm : BasicAlgorithm {

    var ratio: Ratio? = null

    constructor() : super() {
        this.ratio = SimpleRatio()
    }

    constructor(stringFunction: ToStringFunction) : super(stringFunction) {}

    constructor(ratio: Ratio) : super() {
        this.ratio = ratio
    }


    constructor(stringFunction: ToStringFunction, ratio: Ratio) : super(stringFunction) {
        this.ratio = ratio
    }

    abstract fun apply(s1: String, s2: String, ratio: Ratio, stringFunction: ToStringFunction): Int

    fun with(ratio: Ratio): RatioAlgorithm {
        this.ratio = ratio
        return this
    }

    fun apply(s1: String, s2: String, ratio: Ratio): Int {
        return apply(s1, s2, ratio, stringFunction!!)
    }

    override fun apply(s1: String, s2: String, stringProcessor: ToStringFunction): Int {
        return apply(s1, s2, ratio!!, stringProcessor)
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy