trait PathSegment[T, A] extends AnyRef
Represents a part of the path string of an URL, containing an information of type T, or an error of type A.
- T
type represented by this PathSegment
- A
type of the error that this PathSegment produces on "illegal" url paths.
- Alphabetic
- By Inheritance
- PathSegment
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Abstract Value Members
- abstract def createSegments(t: T): List[Segment]
Generate a list of segments representing the argument
t.Generate a list of segments representing the argument
t.matchSegmentsandcreateSegmentsshould be (functional) inverse of each other. That is,this.matchSegments(this.createSegments(t)) == Right(PathMathOutput(t, Nil)) - abstract def matchSegments(segments: List[Segment]): Either[A, PathMatchOutput[T]]
Tries to match the list of urldsl.vocabulary.Segments to create an instance of
T.Tries to match the list of urldsl.vocabulary.Segments to create an instance of
T. If it can not, it returns an error indicating the reason of the failure. If it could, it returns the value ofT, as well as the list of unused segments.- segments
The list of urldsl.vocabulary.Segment to match this path segment again.
- returns
The "de-serialized" element with unused segment, if successful.
For example, a segment that matches simply a String in the first segment, when giving segments like List(Segment("hello"), Segment("3")) will return Right(PathMatchOutput("hello", List(Segment("3")))
Example:
Concrete Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##(): Int
- Definition Classes
- AnyRef → Any
- final def /[U](that: PathSegment[U, A])(implicit ev: Tupler[T, U]): PathSegment[Out, A]
Concatenates
thisurldsl.language.PathSegment withthatone, "tupling" the types with the Tupler rules. - final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ?[ParamsType, QPError](params: QueryParameters[ParamsType, QPError]): PathSegmentWithQueryParams[T, A, ParamsType, QPError]
- final def as[U](fromTToU: (T) => U, fromUToT: (U) => T): PathSegment[U, A]
Casts this PathSegment to the new type U.
Casts this PathSegment to the new type U. The conversion functions should form an exception-free bijection between T and U (or at least an embedding, if you know that you are doing).
- final def as[U](implicit codec: Codec[T, U]): PathSegment[U, A]
Casts this PathSegment to the new type U.
Casts this PathSegment to the new type U. Note that the urldsl.vocabulary.Codec must be an exception-free bijection between T and U (or at least an embedding, if you know that you are doing).
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- final def createPath(encoder: UrlStringGenerator)(implicit ev: =:=[Unit, T]): String
- final def createPath()(implicit ev: =:=[Unit, T]): String
Sugar when
T =:= Unit - def createPath(t: T, encoder: UrlStringGenerator = UrlStringGenerator.default): String
Concatenates the segments generated by
createSegments - final def createSegments()(implicit ev: =:=[Unit, T]): List[Segment]
Sugar when
T =:= Unit - final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- final def filter(predicate: (T) => Boolean)(implicit ev: =:=[DummyError, A]): PathSegment[T, A]
Sugar for when
A =:= DummyError - final def filter(predicate: (T) => Boolean, error: (List[Segment]) => A): PathSegment[T, A]
Adds an extra satisfying criteria to the de-serialized output of this urldsl.language.PathSegment.
Adds an extra satisfying criteria to the de-serialized output of this urldsl.language.PathSegment.
The new de-serialization works as follows: - if the initial de-serialization fails, then it returns the generated error - otherwise, if the de-serialized element satisfies the predicate, then it returns the element - if the predicate is false, generates the given
errorby feeding it the segments that it tried to match.This can be useful in, among others, two scenarios: - enforce bigger restriction on a segment (e.g., from integers to positive integer, regex match...) - in a multi-part segment, ensure consistency between the different component (e.g., a range of two integers that should not be too large...)
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def matchPath(path: String, decoder: UrlStringDecoder = UrlStringDecoder.defaultDecoder): Either[A, T]
- def matchRawUrl(url: String, urlStringParserGenerator: UrlStringParserGenerator = UrlStringParserGenerator.defaultUrlStringParserGenerator): Either[A, T]
Matches the given raw
urlusing the given urldsl.url.UrlStringParserGenerator for creating a urldsl.url.UrlStringParser.Matches the given raw
urlusing the given urldsl.url.UrlStringParserGenerator for creating a urldsl.url.UrlStringParser.This method doesn't return the information about the remaining unused segments. The thought leading to this is that urldsl.vocabulary.PathMatchOutput are supposed to be internal mechanics, while this method is supposed to be the exposed interface of this urldsl.language.PathSegment.
- url
the url to parse. It has to be a well formed URL, otherwise this could raise an exception, depending on the provided urldsl.url.UrlStringParserGenerator.
- urlStringParserGenerator
the urldsl.url.UrlStringParserGenerator used to create the urldsl.url.UrlStringParser that will actually parse the url to create the segments. The default one is usually a good choice. It has different implementations in JVM and JS, but they *should* behave the same way.
- returns
the output contained in the url, or the error if something fails.
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def ||[U](that: PathSegment[U, A]): PathSegment[Either[T, U], A]
Builds a PathSegment that first tries to match with this one, then tries to match with
thatone.Builds a PathSegment that first tries to match with this one, then tries to match with
thatone. If both fail, the error of the second is returned (todo[behaviour]: should that change?)