DSL
The object allowing the access to the DSL for creating JsonTupleTemplates.
This objects contains all methods for creating a tuple template with simplicity and conciseness. The starting point are the complete and partial methods, to be used for allowing the creation of new JsonTupleTemplates. These are the only top-level templates allowed to be created. All other templates can be used as elements of this type of templates. An example of syntax using this DSL is:
complete(string in ("event-type-1", "event-type-2"), *, anyOf(bool, nil))
If a constant value is to be used for matching, it can be inserted as any other template in a tuple template, for example:
partial("event-type-1", 5.33f, *)
The use of this DSL is the main tool for creating new JsonTemplates of any kind, because it is able to limit the ways in which a template can be created. The API exposed by the JsonTemplate trait and all its subtypes it is not designed to capture the constraints of their creation or the use cases for this library, while this DSL is. Being so, it is highly encouraged to use DSL for creating templates.
Attributes
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
DSL.type
Members list
Value members
Concrete methods
Returns a new "any" template, capable of matching any JsonElement.
Returns a new "allOf" template, a template that matches a JsonElement if and only if all templates which it contains match.
Returns a new "allOf" template, a template that matches a JsonElement if and only if all templates which it contains match.
This method returns a special meta-template, which is built on top of other templates. For it to be matching a JsonElement, all templates that it contains must match the given JsonElement.
Value parameters
- templates
-
the templates to be used by this template
Attributes
- Returns
-
a template that matches a JsonElement if and only if all templates which it contains match
Returns a new "anyOf" template, a template that matches a JsonElement if and only if any template which it contains match.
Returns a new "anyOf" template, a template that matches a JsonElement if and only if any template which it contains match.
This method returns a special meta-template, which is built on top of other templates. For it to be matching a JsonElement, any template that it contains must match the given JsonElement.
Value parameters
- templates
-
the templates to be used by this template
Attributes
- Returns
-
a template that matches a JsonElement if and only if any template which it contains match
Entrypoint method for this DSL, allows for creating a new JsonTupleTemplate without allowing for additional items.
Entrypoint method for this DSL, allows for creating a new JsonTupleTemplate without allowing for additional items.
This methods is one of the two to be used for creating a new JsonTuple template, the difference between them being that this one considers all JsonTemplates specified in it to be matched in the exact number with the JsonElements in the given JsonTuple. A tuple with an arity greater or smaller than the number of elements in the created template will automatically fail the match, but not with an equal arity. The syntax for creating a new template is simple: calling this method while passing all the templates, in order, that must be matched with the corresponding elements in a given JsonTuple. Every template must be created using this DSL.
Value parameters
- templates
-
the templates that constitutes the elements of the returned JsonTupleTemplate
Attributes
- Returns
-
a new JsonTupleTemplate as specified
Returns a new "null" template, capable of matching only the null
value.
Returns a new "null" template, capable of matching only the null
value.
Attributes
Returns a new "not" template, a template that matches a JsonElement if and only if the template which it contains does not match.
Returns a new "not" template, a template that matches a JsonElement if and only if the template which it contains does not match.
This method returns a special meta-template, which is built on top of another template. For it to be matching a JsonElement, the template that it contains must not match the given JsonElement.
Value parameters
- template
-
the template to be used by this template
Attributes
- Returns
-
a template that matches a JsonElement if and only if the template which it contains does not match
Returns a new "oneOf" template, a template that matches a JsonElement if and only if exactly one template which it contains match.
Returns a new "oneOf" template, a template that matches a JsonElement if and only if exactly one template which it contains match.
This method returns a special meta-template, which is built on top of other templates. For it to be matching a JsonElement, exactly one template that it contains must match the given JsonElement.
Value parameters
- templates
-
the templates to be used by this template
Attributes
- Returns
-
a template that matches a JsonElement if and only if exactly one template which it contains match
Entrypoint method for this DSL, allows for creating a new JsonTupleTemplate allowing for additional items.
Entrypoint method for this DSL, allows for creating a new JsonTupleTemplate allowing for additional items.
This methods is one of the two to be used for creating a new JsonTuple template, the difference between them being that this one considers all JsonTemplates specified in it to be matched by a number of JsonElements in the given JsonTuple which is at least equal to the number of the elements. A tuple with an arity smaller that the number of elements in the created template will automatically fail the match, but not with an arity equal or greater. The syntax for creating a new template is simple: calling this method while passing all the templates, in order, that must be matched with the corresponding elements in a given JsonTuple. Every template must be created using this DSL.
Value parameters
- templates
-
the templates that constitutes the elements of the returned JsonTupleTemplate
Attributes
- Returns
-
a new JsonTupleTemplate as specified