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

commonMain.PathFragments.kt Maven / Gradle / Ivy

There is a newer version: 0.23.0
Show newest version
package io.kform

import kotlin.js.JsName

/** Fragment of a path. */
@JsName("PathFragmentKt")
public sealed class PathFragment {
    /** Path fragment representing the root path. */
    public data object Root : PathFragment()

    /** Path fragment representing the current path (`"."` in string notation). */
    public data object CurrentPath : PathFragment()

    /** Parent fragment representing the parent path (`".."` in string notation). */
    public data object ParentPath : PathFragment()
}

/** Fragment of an absolute path. */
@JsName("AbsolutePathFragmentKt")
public sealed class AbsolutePathFragment : PathFragment() {
    /**
     * Path fragment representing an identifier [id]. In string notation, the id fragment with [id]
     * `"x"` would be represented as `x`; if the string version of the fragment conflicts with a
     * different fragment, then the fragment is escaped, e.g. the id fragment with [id] `"*"` would
     * be represented as `~*` in string notation.
     */
    public data class Id(val id: String) : AbsolutePathFragment() {
        /**
         * Creates a new [Id] path fragment with [id] transformed into a string via `id.toString()`.
         */
        public constructor(id: Any) : this(id.toString())
    }

    /**
     * Path fragment representing the "end" of a collection (`"-"` in string notation).
     *
     * This fragment represents the fictional element after the last element of a collection.
     */
    public data object CollectionEnd : AbsolutePathFragment()

    /**
     * Wildcard fragment (`"*"` in string notation).
     *
     * Wildcard fragments match against any other fragments.
     */
    public data object Wildcard : AbsolutePathFragment()

    /**
     * Recursive wildcard fragment (`"**"` in string notation).
     *
     * Recursive wildcard fragments match against zero or more any other fragments.
     */
    public data object RecursiveWildcard : AbsolutePathFragment()
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy