QueryParameters

trait QueryParameters[Q, +A] extends UrlPart[Q, A]
Companion
object
trait UrlPart[Q, A]
class Object
trait Matchable
class Any

Value members

Abstract methods

def createParams(q: Q): Map[String, Param]

Generate a map of parameters representing the argument q.

Generate a map of parameters representing the argument q.

matchParams and createParams should be (functional) inverse of each other. That is, this.matchParams(this.createParams(q)) == Right(ParamMathOutput(q, Map())) (this property is called "LeftInverse" in the tests)

def matchParams(params: Map[String, Param]): Either[A, ParamMatchOutput[Q]]

Tries to match the map of urldsl.vocabulary.Params to create an instance of Q. If it can not, it returns an error indicating the reason of the failure. If it could, it returns the value of Q, as well as the list of unused parameters.

Tries to match the map of urldsl.vocabulary.Params to create an instance of Q. If it can not, it returns an error indicating the reason of the failure. If it could, it returns the value of Q, as well as the list of unused parameters.

Value Params
params

The map of urldsl.vocabulary.Param to match this path segment again.

Returns

The "de-serialized" element with unused parameters, if successful.

Example

For example, if you try to match a param "name" as String and "age" as Int, calling matchParams on Map("name" -> Param(List("Alice")), "age" -> Param(List("24"), "year" -> Param(List("2020"))) will return Right(ParamMatchOutput(("Alice", 24), Map("year" -> Param(List("2020")))

Concrete methods

final def &[R, A1 >: A](that: QueryParameters[R, A1])(ev: Tupler[Q, R]): QueryParameters[Out, A1]

Adds that QueryParameters to this one, "tupling" the returned type with the implicit urldsl.language.Tupler

Adds that QueryParameters to this one, "tupling" the returned type with the implicit urldsl.language.Tupler

The matching and writing of strings is functionally commutative under &, but the returned type Q is not. So, if you have two parameters, one matching an Int and the other one a String, depending on the order in which & is called, you can end up with "Q = (Int, String)" or "Q = (String, Int)". This property is called "QuasiCommutativity" in the tests.

final def ?: QueryParameters[Option[Q], A]

When these query parameters return an error, transform it to None instead.

When these query parameters return an error, transform it to None instead.

This should be used to represent (possibly) missing parameters.

final def as[R](codec: Codec[Q, R]): QueryParameters[R, A]

Casts this QueryParameters to the new type R. Note that the urldsl.vocabulary.Codec must be an exception-free bijection between Q and R.

Casts this QueryParameters to the new type R. Note that the urldsl.vocabulary.Codec must be an exception-free bijection between Q and R.

final def createParamsMap(q: Q, encoder: UrlStringGenerator): Map[String, List[String]]

Generates a Map of parameters representing the argument q. The keys are not encoded, but the values are lists of encoded strings.

Generates a Map of parameters representing the argument q. The keys are not encoded, but the values are lists of encoded strings.

final def createParamsString(q: Q, encoder: UrlStringGenerator): String

Generates the query string representing the argument q. This String can be used to be part of a URL.

Generates the query string representing the argument q. This String can be used to be part of a URL.

final def createPart(q: Q, encoder: UrlStringGenerator): String
final def filter[A1 >: A](predicate: Q => Boolean, error: Map[String, Param] => A1): QueryParameters[Q, A1]

Adds an extra satisfying criteria to the output of this QueryParameters. If the output satisfies the given predicate, then it is left unchanged. Otherwise, it returns the given error.

Adds an extra satisfying criteria to the output of this QueryParameters. If the output satisfies the given predicate, then it is left unchanged. Otherwise, it returns the given error.

Note that it doesn't check that arguments given to createParams satisfy this predicate // todo[behaviour]: should that change?

Value Params
error

the generated error in case it does not satisfy it

predicate

the additional predicate that the output must satisfy

Returns

a new QueryParameters instance with the same types

Example
         param[Int]("age").filter(_ >= 0, (params: Map[String, Param]) => someError(params))
final def filter(predicate: Q => Boolean)(ev: A <:< DummyError): QueryParameters[Q, DummyError]

Sugar for when A =:= DummyError.

Sugar for when A =:= DummyError.

def matchQueryString(queryString: String, decoder: UrlStringDecoder): Either[A, Q]
def matchRawUrl(url: String, urlStringParserGenerator: UrlStringParserGenerator): Either[A, Q]
final def withFragment[FragmentType, FragmentError](fragment: Fragment[FragmentType, FragmentError]): PathQueryFragmentRepr[Unit, Nothing, Q, A, FragmentType, FragmentError]

Associates this QueryParameters with the given Fragment in order to match raw urls satisfying both conditions, and returning the outputs from both.

Associates this QueryParameters with the given Fragment in order to match raw urls satisfying both conditions, and returning the outputs from both.

The path part of the url will be ignored (and will return Unit).

Inherited methods

final def createPart(ev: Unit =:= Q): String

Sugar when T =:= Unit

Sugar when T =:= Unit

Inherited from
UrlPart
final def createPart(encoder: UrlStringGenerator)(ev: Unit =:= Q): String

Sugar when T =:= Unit

Sugar when T =:= Unit

Inherited from
UrlPart