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
- All
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
thisPathSegment 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](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.
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
final
def
createPath[Generator <: UrlStringGenerator]()(implicit ev: =:=[Unit, T], generator: Generator): String
Sugar when
T =:= Unit -
def
createPath[Generator <: UrlStringGenerator](t: T)(implicit generator: Generator): 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: Any): 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 PathSegment.
Adds an extra satisfying criteria to the de-serialized output of this 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[_]
- 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 = ...): Either[A, T]
Matches the given raw
urlusing the implicit UrlStringParser of typeUrlParser.Matches the given raw
urlusing the implicit UrlStringParser of typeUrlParser.This method doesn't return the information about the remaining unused segments. The thought leading to this is that PathMatchOutput are supposed to be internal mechanics, while this method is supposed to be the exposed interface the this PathSegment.
- url
the url to parse
- urlStringParserGenerator
the UrlStringParserGenerator used to create the UrlStringParser that will actually parse the url to create the segments. The urldsl.url.JavaNetUrlGenerator is often a good choice on both the JVM and JS (which are currently the two only targeted platforms)
- returns
the output contained in the url, or the error is 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( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @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?)