Path

@Serializable(with = Path.Serializer::class)
open class Path(fragments: List<PathFragment> = emptyList())(source)

Representation of a path as a list of path fragments.

Paths represent locations of data, possibly relatively to other locations: e.g. the location of a value relative to the location of another value. They can also represent locations of data from the root when they contain a root fragment.

Inheritors

Constructors

Link copied to clipboard
constructor(stringPath: String)

Creates a path from its string notation. E.g. "./path/to/somewhere".

constructor(fragments: List<PathFragment> = emptyList())

Types

Link copied to clipboard
object Companion
Link copied to clipboard
object Serializer : KSerializer<Path>

Path serialiser, serialising paths as strings.

Properties

Link copied to clipboard

List of fragments representing this path.

Functions

Link copied to clipboard
fun append(vararg fragments: PathFragment): Path

Returns the path resulting from appending fragments to this path.

Link copied to clipboard
suspend fun <T> Path.convertTableRowIdsToIndices(formSchema: Schema<T>, formValue: T): AbsolutePath

Utility function which converts a path where table rows are indexed by their id into a path where said rows are indexed by their index in the corresponding table within the provided form value formValue (with schema formSchema).

Link copied to clipboard
suspend fun <T> Path.convertTableRowIndicesToIds(formSchema: Schema<T>, formValue: T): AbsolutePath

Utility function which converts a path where table rows are indexed by their index into a path where said rows are indexed by their id in the corresponding table within the provided form value formValue (with schema formSchema).

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean

Returns whether this path equals other.

Link copied to clipboard
open fun fragment(index: Int): PathFragment

Returns the fragment of this path with index index.

Link copied to clipboard
open operator fun get(index: Int): PathFragment

Returns the fragment of this path with index index.

Link copied to clipboard
open override fun hashCode(): Int

Returns the hash code for this path.

Link copied to clipboard
open operator fun iterator(): Iterator<PathFragment>

Returns an iterator over the path's fragments.

Link copied to clipboard
fun join(vararg stringPaths: String): Path

Returns the path resulting from joining the provided paths in string notation stringPaths together with this path.

fun join(vararg paths: Path): Path

Returns the path resulting from joining paths together with this path.

Link copied to clipboard
open fun parent(): Path

Returns a new path representing the parent of this path.

Link copied to clipboard
open operator fun plus(stringPath: String): Path

Returns the path resulting from joining the path in string notation stringPath together with this path. Equivalent to join(stringPath).

open operator fun plus(path: Path): Path

Returns the path resulting from joining path together with this path. Equivalent to join(path).

operator fun plus(fragment: PathFragment): Path

Returns the path resulting from appending fragment to this path. Equivalent to append(fragment).

Link copied to clipboard
fun resolve(): Path

Returns the result of resolving this path. Resolving the path removes unnecessary fragments such as the current path fragment.

open fun resolve(vararg stringPaths: String): Path

Returns the path resulting from resolving a list of paths in string notation stringPaths against this path.

open fun resolve(vararg paths: Path): Path

Returns the path resulting from resolving a list of paths against this path.

Link copied to clipboard

Converts the receiver path into an absolute path, if it wasn't one already.

Link copied to clipboard
open override fun toString(): String

Returns the path in string notation.