Class PrimitivePatterns
All patterns obtainable from this class are deterministic and bind no variables.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionA pattern that matches finite floating-point values.A pattern that matches infinite floating-point values.A pattern that matches the valuefalse.A pattern that matches the valuetrue.A pattern that matches the floating-point valueNaN.A pattern that matches negative floating-point values.A pattern that matches negative integer values.A pattern that matches positive floating-point values.A pattern that matches positive integer values.A pattern that matches the floating-point value zero.A pattern that matches the integer value zero. -
Method Summary
Modifier and TypeMethodDescriptionstatic <A> Pattern<A> compare(Comparator<? super A> comparator, A other, Pattern<? super Integer> body) Returns a pattern that matches objects based on comparison with a given object using the given ordering.static <A extends Comparable<? super A>>
Pattern<A> Returns a pattern that matches objects based on comparison with a given object using the natural ordering.Return a pattern that matches an optional value if present.static <A> Pattern<A> eq(A other) Returns a pattern that matches objects identically equal to a given reference.static <A> Pattern<A> eqNull()Returns a pattern that matches only thenullreference.static <A> Pattern<A> equal(A other) Returns a pattern that matches objects equal to a given reference.static <A extends Comparable<? super A>>
Pattern<A> greaterThan(A other) Returns a pattern that matches objects greater than a given object using natural ordering.static <A> Pattern<A> greaterThan(Comparator<? super A> comparator, A other) Returns a pattern that matches objects greater than a given object using the given ordering.static <A extends Comparable<? super A>>
Pattern<A> greaterThanOrEqual(A other) Returns a pattern that matches objects greater than or equal to a given object using natural ordering.static <A> Pattern<A> greaterThanOrEqual(Comparator<? super A> comparator, A other) Returns a pattern that matches objects greater than or equal to a given object using the given ordering.static <A extends Comparable<? super A>>
Pattern<A> lessThan(A other) Returns a pattern that matches objects less than a given object using natural ordering.static <A> Pattern<A> lessThan(Comparator<? super A> comparator, A other) Returns a pattern that matches objects less than a given object using the given ordering.static <A extends Comparable<? super A>>
Pattern<A> lessThanOrEqual(A other) Returns a pattern that matches objects less than or equal to a given object using natural ordering.static <A> Pattern<A> lessThanOrEqual(Comparator<? super A> comparator, A other) Returns a pattern that matches objects less than or equal to a given object using the given ordering.static <A> Pattern<A> neq(A other) Returns a pattern that matches objects not identically equal to a given reference.static <A> Pattern<A> neqNull()Returns a pattern that matches anything except thenullreference.static <A> Pattern<A> nequal(A other) Returns a pattern that matches objects not equal to a given reference.Return a pattern that matches an optional value if present.range(char from, char to) Returns a pattern that matches characters in a given range.
-
Field Details
-
isTrue
A pattern that matches the valuetrue. -
isFalse
A pattern that matches the valuefalse. -
positiveInteger
A pattern that matches positive integer values. -
zeroInteger
A pattern that matches the integer value zero. -
negativeInteger
A pattern that matches negative integer values. -
positiveDouble
A pattern that matches positive floating-point values. -
zeroDouble
A pattern that matches the floating-point value zero. -
negativeDouble
A pattern that matches negative floating-point values. -
nanDouble
A pattern that matches the floating-point valueNaN. -
finiteDouble
A pattern that matches finite floating-point values. -
infiniteDouble
A pattern that matches infinite floating-point values.
-
-
Method Details
-
equal
Returns a pattern that matches objects equal to a given reference. Equality is determined as if byObjects.equals(java.lang.Object, java.lang.Object).A pattern returned by this method is deterministic and binds no variables.
- Type Parameters:
A- the target type of objects to match against- Parameters:
other- an object to compare with ornull- Returns:
- a pattern that matches objects equal to
other
-
nequal
Returns a pattern that matches objects not equal to a given reference. Equality is determined as if byObjects.equals(java.lang.Object, java.lang.Object).A pattern returned by this method is deterministic and binds no variables.
- Type Parameters:
A- the target type of objects to match against- Parameters:
other- an object to compare with ornull- Returns:
- a pattern that matches objects not equal to
other
-
eq
Returns a pattern that matches objects identically equal to a given reference. Equality is determined by==.A pattern returned by this method is deterministic and binds no variables.
- Type Parameters:
A- the target type of objects to match against- Parameters:
other- an object to compare with ornull- Returns:
- a pattern that matches objects identically equal to
other
-
neq
Returns a pattern that matches objects not identically equal to a given reference. Equality is determined by!=.A pattern returned by this method is deterministic and binds no variables.
- Type Parameters:
A- the target type of objects to match against- Parameters:
other- an object to compare with ornull- Returns:
- a pattern that matches objects identically equal to
other
-
compareTo
public static <A extends Comparable<? super A>> Pattern<A> compareTo(@Opt A other, Pattern<? super Integer> body) Returns a pattern that matches objects based on comparison with a given object using the natural ordering. Matching succeeds if and only if the result of comparing the target object viaComparable.compareTo(T)to a given object matches a givenintpattern.A pattern returned by this method inherits determinism and variable bindings from the given pattern.
- Type Parameters:
A- the target type of objects to match against- Parameters:
other- an object to compare with ornullbody- a pattern to match the comparison result- Returns:
- a pattern that matches objects with
bodybased on comparison withother - Throws:
NullPointerException- ifbodyis null
-
compare
public static <A> Pattern<A> compare(Comparator<? super A> comparator, @Opt A other, Pattern<? super Integer> body) Returns a pattern that matches objects based on comparison with a given object using the given ordering. Matching succeeds if and only if the result of comparing the target object viaComparable.compareTo(T)to a given object matches a givenintpattern.A pattern returned by this method inherits determinism and variable bindings from the given pattern.
- Type Parameters:
A- the target type of objects to match against- Parameters:
comparator- the comparator that specifies the orderingother- an object to compare with ornullbody- a pattern to match the comparison result- Returns:
- a pattern that matches objects with
bodybased on comparison withother - Throws:
NullPointerException- ifcomparatororbodyis null
-
lessThan
Returns a pattern that matches objects less than a given object using natural ordering. Ordering is determined byComparable.compareTo(T).A pattern returned by this method is deterministic and binds no variables.
- Type Parameters:
A- the target type of objects to match against- Parameters:
other- an object to compare with- Returns:
- a pattern that matches objects less than
other - Throws:
NullPointerException- ifotheris null
-
lessThanOrEqual
Returns a pattern that matches objects less than or equal to a given object using natural ordering. Ordering is determined byComparable.compareTo(T).A pattern returned by this method is deterministic and binds no variables.
- Type Parameters:
A- the target type of objects to match against- Parameters:
other- an object to compare with- Returns:
- a pattern that matches objects less than or equal to
other - Throws:
NullPointerException- ifotheris null
-
greaterThan
Returns a pattern that matches objects greater than a given object using natural ordering. Ordering is determined byComparable.compareTo(T).A pattern returned by this method is deterministic and binds no variables.
- Type Parameters:
A- the target type of objects to match against- Parameters:
other- an object to compare with- Returns:
- a pattern that matches objects greater than
other - Throws:
NullPointerException- ifotheris null
-
greaterThanOrEqual
Returns a pattern that matches objects greater than or equal to a given object using natural ordering. Ordering is determined byComparable.compareTo(T).A pattern returned by this method is deterministic and binds no variables.
- Type Parameters:
A- the target type of objects to match against- Parameters:
other- an object to compare with- Returns:
- a pattern that matches objects greater than or equal to
other - Throws:
NullPointerException- ifotheris null
-
lessThan
Returns a pattern that matches objects less than a given object using the given ordering. Comparisons involving null may or may not be supported, depending on the ordering implementation.A pattern returned by this method is deterministic and binds no variables.
- Type Parameters:
A- the target type of objects to match against- Parameters:
comparator- the comparator that specifies the orderingother- an object to compare with- Returns:
- a pattern that matches objects less than
otheraccording tocomparator - Throws:
NullPointerException- ifcomparatoris null- See Also:
-
lessThanOrEqual
Returns a pattern that matches objects less than or equal to a given object using the given ordering. Comparisons involving null may or may not be supported, depending on the ordering implementation.A pattern returned by this method is deterministic and binds no variables.
- Type Parameters:
A- the target type of objects to match against- Parameters:
comparator- the comparator that specifies the orderingother- an object to compare with- Returns:
- a pattern that matches objects less than or equal to
otheraccording tocomparator - Throws:
NullPointerException- ifcomparatoris null- See Also:
-
greaterThan
Returns a pattern that matches objects greater than a given object using the given ordering. Comparisons involving null may or may not be supported, depending on the ordering implementation.A pattern returned by this method is deterministic and binds no variables.
- Type Parameters:
A- the target type of objects to match against- Parameters:
comparator- the comparator that specifies the orderingother- an object to compare with- Returns:
- a pattern that matches objects greater than
otheraccording tocomparator - Throws:
NullPointerException- ifcomparatoris null- See Also:
-
greaterThanOrEqual
Returns a pattern that matches objects greater than or equal to a given object using the given ordering. Comparisons involving null may or may not be supported, depending on the ordering implementation.A pattern returned by this method is deterministic and binds no variables.
- Type Parameters:
A- the target type of objects to match against- Parameters:
comparator- the comparator that specifies the orderingother- an object to compare with- Returns:
- a pattern that matches objects greater than or equal to
otheraccording tocomparator - Throws:
NullPointerException- ifcomparatoris null- See Also:
-
eqNull
Returns a pattern that matches only thenullreference.A pattern returned by this method is deterministic and binds no variables.
- Type Parameters:
A- the target type of objects to match against- Returns:
- a pattern that matches only
null
-
neqNull
Returns a pattern that matches anything except thenullreference.A pattern returned by this method is deterministic and binds no variables.
- Type Parameters:
A- the target type of objects to match against- Returns:
- a pattern that matches anything except
null
-
range
Returns a pattern that matches characters in a given range.A pattern returned by this method is deterministic and binds no variables.
- Parameters:
from- the lower bound of the range (inclusive)to- the upper bound of the range (inclusive)- Returns:
- a pattern that matches characters greater or equal to
fromand less or equal toto
-
present
Return a pattern that matches an optional value if present. Empty targets are not matched.- Type Parameters:
A- the target type of objects to match against- Parameters:
body- the pattern to match a present value- Returns:
- a pattern that matches a present optional value with
body, or fails for empty targets - Throws:
NullPointerException- ifbodyis null- See Also:
-
emptyOr
Return a pattern that matches an optional value if present. Empty targets are matched.- Type Parameters:
A- the target type of objects to match against- Parameters:
body- the pattern to match a present value- Returns:
- a pattern that matches a present optional value with
body, or succeeds silently for empty targets - Throws:
NullPointerException- ifbodyis null- See Also:
-