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

com.fireflysource.net.http.server.impl.matcher.AbstractPreciseMatcher.kt Maven / Gradle / Ivy

There is a newer version: 5.0.2
Show newest version
package com.fireflysource.net.http.server.impl.matcher

import com.fireflysource.net.http.server.Matcher
import com.fireflysource.net.http.server.Router
import java.util.*
import kotlin.collections.HashMap


abstract class AbstractPreciseMatcher : Matcher {

    protected val map: MutableMap> = HashMap()

    override fun add(rule: String, router: Router) {
        map.computeIfAbsent(rule) { TreeSet() }.add(router)
    }

    override fun match(value: String): Matcher.MatchResult? {
        val routers = map[value]
        return if (routers != null && routers.isNotEmpty()) {
            Matcher.MatchResult(routers, emptyMap(), matchType)
        } else null
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy