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

in.specmatic.core.pattern.URLScheme.kt Maven / Gradle / Ivy

Go to download

Turn your contracts into executable specifications. Contract Driven Development - Collaboratively Design & Independently Deploy MicroServices & MicroFrontends. Deprecation Notice for group ID "in.specmatic" ****************************************************************************************************** Updates for "specmatic-core" will no longer be available under the deprecated group ID "in.specmatic". Please update your dependencies to use the new group ID "io.specmatic". ******************************************************************************************************

There is a newer version: 1.3.39
Show newest version
package `in`.specmatic.core.pattern

import `in`.specmatic.core.value.StringValue

enum class URLScheme(val schemes: List) {
    HTTP(listOf("http")) {
        override val prefix = "${schemes.first()}://"
        override val type: String = "an http url"
    },
    HTTPS(listOf("https")) {
        override val prefix = "${schemes.first()}://"
        override val type: String = "an https url"
    },
    PATH(emptyList()) {
        override val prefix = ""
        override val type: String = "a url path"

        override fun matches(url: StringValue): Boolean = true
        override val tld: String = ""
    },
    EITHER(listOf("http", "https")) {
        override val prefix = "${schemes.first()}://"
        override val type: String = "either an http or or an https url"
    };

    abstract val prefix: String
    abstract val type: String
    open val tld: String = ".com"
    open fun matches(url: StringValue): Boolean = schemes.any { url.string.startsWith(it) }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy