Class GeneralMatchers


  • public class GeneralMatchers
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private GeneralMatchers()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> org.hamcrest.Matcher<T> baseMatcher​(java.lang.String descriptionText, java.util.function.Predicate<T> predicate)
      Creates a matcher that matches when the given predicate returns true.
      static <S,​T extends S>
      org.hamcrest.Matcher<S>
      typeSafeMatcher​(java.lang.Class<T> expectedType, java.lang.String descriptionText, java.util.function.Function<S,​java.lang.String> describeActual, java.util.function.Predicate<T> predicate)
      Creates a matcher that matches when the passed-in object is not null, is an instance of the given type, and the given predicate returns true when that object is passed into it.
      static <S,​T extends S>
      org.hamcrest.Matcher<S>
      typeSafeMatcher​(java.lang.Class<T> expectedType, java.lang.String descriptionText, java.util.function.Predicate<T> predicate)
      Creates a matcher that matches when the passed-in object is not null, is an instance of the given type, and the given predicate returns true when that object is passed into it.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • GeneralMatchers

        private GeneralMatchers()
    • Method Detail

      • baseMatcher

        public static <T> org.hamcrest.Matcher<T> baseMatcher​(java.lang.String descriptionText,
                                                              java.util.function.Predicate<T> predicate)
        Creates a matcher that matches when the given predicate returns true.
        Parameters:
        descriptionText - describes what the matcher tries to match. This is used to explain what happened when a match fails.
        predicate - the predicate that the passed-in object must pass (i.e. predicate.apply(object) returns true) to match
      • typeSafeMatcher

        public static <S,​T extends S> org.hamcrest.Matcher<S> typeSafeMatcher​(java.lang.Class<T> expectedType,
                                                                                    java.lang.String descriptionText,
                                                                                    java.util.function.Predicate<T> predicate)
        Creates a matcher that matches when the passed-in object is not null, is an instance of the given type, and the given predicate returns true when that object is passed into it.
        Parameters:
        expectedType - the class that the passed-in object must be an instance of to match
        descriptionText - describes what the matcher tries to match. This is used to explain what happened when a match fails.
        predicate - the predicate that the passed-in object must pass (i.e. predicate.apply(object) returns true) to match
      • typeSafeMatcher

        public static <S,​T extends S> org.hamcrest.Matcher<S> typeSafeMatcher​(java.lang.Class<T> expectedType,
                                                                                    java.lang.String descriptionText,
                                                                                    java.util.function.Function<S,​java.lang.String> describeActual,
                                                                                    java.util.function.Predicate<T> predicate)
        Creates a matcher that matches when the passed-in object is not null, is an instance of the given type, and the given predicate returns true when that object is passed into it.
        Parameters:
        expectedType - the class that the passed-in object must be an instance of to match
        descriptionText - describes what the matcher tries to match. This is used to explain what happened when a match fails.
        describeActual - a Function which takes as input the "actual" object and produces a String that clearly describes the "actual" object. This is used for producing a human-readable description of the difference between the "expected" and "actual" if the Matcher fails
        predicate - the predicate that the passed-in object must pass (i.e. predicate.apply(object) returns true) to match