Package org.refcodes.matcher
Class MatcherSugar
- java.lang.Object
-
- org.refcodes.matcher.MatcherSugar
-
public class MatcherSugar extends java.lang.Object
Declarative syntactic sugar which may be statically imported in order to allow declarative definitions for theMatcher
elements.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
MatcherSugar()
Instantiates a new matcher sugar.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <M> Matcher<M>
and(Matcher<M>... aMatchers)
static <M> Matcher<M>
any()
Import static ANY implementation of aMatcher
which always returnstrue
.static <M> Matcher<M>
equalWith(M aMatchee)
Import static EQUAL WITHMatcher
, comparing its matchee with the matchee provided to theMatcher.isMatching(Object)
method for equality.static <M extends java.lang.Comparable<M>>
Matcher<M>greaterOrEqualThan(M aMatchee)
Import static GREATER OR EQUAL THANMatcher
, comparing its matchee with the matchee provided to theMatcher.isMatching(Object)
method using theComparable.compareTo(Object)
method to be implemented by the matchees.static <M extends java.lang.Comparable<M>>
Matcher<M>greaterThan(M aMatchee)
Import static GREATER THANMatcher
, comparing its matchee with the matchee provided to theMatcher.isMatching(Object)
method using theComparable.compareTo(Object)
method to be implemented by the matchees.static <M> Matcher<M>
isAssignableFrom(java.lang.Class<?> aMatcheeType)
Static import IS ASSIGNABLE FROMMatcher
using the type of the matchees being the criteria to determine a match.static <M extends java.lang.Comparable<M>>
Matcher<M>lessOrEqualThan(M aMatchee)
Import static LESS OR EQUAL THANMatcher
, comparing its matchee with the matchee provided to theMatcher.isMatching(Object)
method using theComparable.compareTo(Object)
method to be implemented by the matchees.static <M extends java.lang.Comparable<M>>
Matcher<M>lessThan(M aMatchee)
Import static LESS THANMatcher
, comparing its matchee with the matchee provided to theMatcher.isMatching(Object)
method using theComparable.compareTo(Object)
method to be implemented by the matchees.static <M> Matcher<M>
none()
Import static NONE implementation of aMatcher
which always returnsfalse
.static <M> Matcher<M>
not(Matcher<M> aMatcher)
Import static NOTMatcher
whoseMatcher.isMatching(Object)
method inverts (NOT) theMatcher.isMatching(Object)
result of the encapsulatedMatcher
.static <M> Matcher<M>
notEqualWith(M aMatchee)
Import static NOT EQUAL WITHMatcher
, comparing its matchee with the matchee provided to theMatcher.isMatching(Object)
method for equality.static <M> Matcher<M>
or(Matcher<M>... aMatchers)
-
-
-
Method Detail
-
isAssignableFrom
public static <M> Matcher<M> isAssignableFrom(java.lang.Class<?> aMatcheeType)
Static import IS ASSIGNABLE FROMMatcher
using the type of the matchees being the criteria to determine a match.- Type Parameters:
M
- The type of the matchee to be matched- Parameters:
aMatcheeType
- The type of the matchee to match.- Returns:
- A
Matcher
by type.
-
not
public static <M> Matcher<M> not(Matcher<M> aMatcher)
Import static NOTMatcher
whoseMatcher.isMatching(Object)
method inverts (NOT) theMatcher.isMatching(Object)
result of the encapsulatedMatcher
.
-
any
public static <M> Matcher<M> any()
Import static ANY implementation of aMatcher
which always returnstrue
.- Type Parameters:
M
- The matchee type.- Returns:
- An ANY
Matcher
.
-
none
public static <M> Matcher<M> none()
Import static NONE implementation of aMatcher
which always returnsfalse
.- Type Parameters:
M
- The matchee type.- Returns:
- A NONE
Matcher
.
-
equalWith
public static <M> Matcher<M> equalWith(M aMatchee)
Import static EQUAL WITHMatcher
, comparing its matchee with the matchee provided to theMatcher.isMatching(Object)
method for equality.- Type Parameters:
M
- The matchee type.- Parameters:
aMatchee
- The matchee with which to match.- Returns:
- An EQUAL WITH
Matcher
.
-
notEqualWith
public static <M> Matcher<M> notEqualWith(M aMatchee)
Import static NOT EQUAL WITHMatcher
, comparing its matchee with the matchee provided to theMatcher.isMatching(Object)
method for equality.- Type Parameters:
M
- The matchee type.- Parameters:
aMatchee
- The matchee with which to match.- Returns:
- An NOT EQUAL WITH
Matcher
.
-
greaterOrEqualThan
public static <M extends java.lang.Comparable<M>> Matcher<M> greaterOrEqualThan(M aMatchee)
Import static GREATER OR EQUAL THANMatcher
, comparing its matchee with the matchee provided to theMatcher.isMatching(Object)
method using theComparable.compareTo(Object)
method to be implemented by the matchees.- Type Parameters:
M
- The matchee type.- Parameters:
aMatchee
- The matchee with which to match.- Returns:
- A NOT EQUAL WITH
Matcher
.
-
greaterThan
public static <M extends java.lang.Comparable<M>> Matcher<M> greaterThan(M aMatchee)
Import static GREATER THANMatcher
, comparing its matchee with the matchee provided to theMatcher.isMatching(Object)
method using theComparable.compareTo(Object)
method to be implemented by the matchees.- Type Parameters:
M
- The matchee type.- Parameters:
aMatchee
- The matchee with which to match.- Returns:
- A GREATER THAN
Matcher
.
-
lessOrEqualThan
public static <M extends java.lang.Comparable<M>> Matcher<M> lessOrEqualThan(M aMatchee)
Import static LESS OR EQUAL THANMatcher
, comparing its matchee with the matchee provided to theMatcher.isMatching(Object)
method using theComparable.compareTo(Object)
method to be implemented by the matchees.- Type Parameters:
M
- The matchee type.- Parameters:
aMatchee
- The matchee with which to match.- Returns:
- An LESS OR EQUAL THAN
Matcher
.
-
lessThan
public static <M extends java.lang.Comparable<M>> Matcher<M> lessThan(M aMatchee)
Import static LESS THANMatcher
, comparing its matchee with the matchee provided to theMatcher.isMatching(Object)
method using theComparable.compareTo(Object)
method to be implemented by the matchees.- Type Parameters:
M
- The matchee type.- Parameters:
aMatchee
- The matchee with which to match.- Returns:
- An LESS THAN
Matcher
.
-
-