Class MatcherSugar



  • public class MatcherSugar
    extends java.lang.Object
    Declarative syntactic sugar which may be statically imported in order to allow declarative definitions for the Matcher elements.
    • Constructor Detail

      • MatcherSugar

        protected MatcherSugar​()
        Instantiates a new matcher sugar.
    • Method Detail

      • isAssignableFrom

        public static <M> Matcher<M> isAssignableFrom​(java.lang.Class<?> aMatcheeType)
        Static import IS ASSIGNABLE FROM Matcher 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.
      • or

        @SafeVarargs
        public static <M> Matcher<M> or​(Matcher<M>... aMatchers)
        Import static OR Matcher, i.e. any of the provided Matcher instances need to match in order for the OR Matcher to match.
        Type Parameters:
        M - The type of the matchee to be matched
        Parameters:
        aMatchers - The Matcher instances to be combined with a logical OR.
        Returns:
        An OR Matcher.
      • and

        @SafeVarargs
        public static <M> Matcher<M> and​(Matcher<M>... aMatchers)
        Import static AND Matcher, i.e. all of the provided Matcher instances need to match in order for the AND Matcher to match.
        Type Parameters:
        M - The type of the matchee to be matched
        Parameters:
        aMatchers - The Matcher instances to be combined with a logical AND.
        Returns:
        An AND Matcher.
      • any

        public static <M> Matcher<M> any​()
        Import static ANY implementation of a Matcher which always returns true.
        Type Parameters:
        M - The matchee type.
        Returns:
        An ANY Matcher.
      • none

        public static <M> Matcher<M> none​()
        Import static NONE implementation of a Matcher which always returns false.
        Type Parameters:
        M - The matchee type.
        Returns:
        A NONE Matcher.
      • equalWith

        public static <M> Matcher<M> equalWith​(M aMatchee)
        Import static EQUAL WITH Matcher, comparing its matchee with the matchee provided to the Matcher.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 WITH Matcher, comparing its matchee with the matchee provided to the Matcher.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 THAN Matcher, comparing its matchee with the matchee provided to the Matcher.isMatching(Object) method using the Comparable.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 THAN Matcher, comparing its matchee with the matchee provided to the Matcher.isMatching(Object) method using the Comparable.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 THAN Matcher, comparing its matchee with the matchee provided to the Matcher.isMatching(Object) method using the Comparable.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 THAN Matcher, comparing its matchee with the matchee provided to the Matcher.isMatching(Object) method using the Comparable.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.