CompositePatternBuilder<T> class
A builder for composite patterns.
A composite pattern is a combination of multiple patterns. When parsing, these are checked in the order in which they are added to the builder with the add method, by trying to parse and seeing if the result is a successful one. When formatting, the patterns are checked in the reverse order, using the predicate provided along with the pattern when calling add. The intention is that patterns are added in 'most precise first' order, and the predicate should indicate whether it can fully represent the given value - so the 'less precise' (and therefore usually shorter) pattern can be used first.
T
: The type of value to be parsed or formatted by the resulting pattern.
This type is mutable, and should not be used between multiple isolates. The patterns created by the build method are immutable.
Constructors
- CompositePatternBuilder()
- Constructs a new instance which initially has no component patterns. At least one component pattern must be added before build is called.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
add(
IPattern< T> pattern, bool formatPredicate(dynamic arg)) → void - Adds a component pattern to this builder.
-
build(
) → IPattern< T> - Builds a composite pattern from this builder. Further changes to this builder will have no impact on the returned pattern.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited