Class ObjectChecker<T>

  • Type Parameters:
    T - the generic type
    Direct Known Subclasses:
    IterableChecker, StringChecker

    public class ObjectChecker<T>
    extends java.lang.Object
    The match wrapper.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) T actualValue  
      (package private) boolean negate  
    • Constructor Summary

      Constructors 
      Constructor Description
      ObjectChecker​(T actualValue, boolean negate)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      void allOf​(org.hamcrest.Matcher<? super T>... matchers)
      Evaluates to true only if ALL of the passed in matchers evaluate to true.
      void anyOf​(org.hamcrest.Matcher<? super T>... matchers)
      Evaluates to true if ANY of the passed in matchers evaluate to true.
      void anything()
      This matcher always evaluates to true.
      StringChecker asString()  
      protected void ensureNonNegative()  
      boolean equals​(java.lang.Object any)
      Deprecated.
      You probably want to use is(Object) method for matcher wrapper.
      (package private) static void fail​(java.lang.Object actualValue, org.hamcrest.Matcher<?> matcher)  
      int hashCode()
      Deprecated.
      This class should not be used with collections
      void hasToString​(java.lang.String expectedToStringValue)  
      void is​(org.hamcrest.Matcher<? super T> matcher)  
      void is​(T value)
      This is equal to check
      void isA​(java.lang.Class<?> type)
      Is the value an instance of a particular type?.
      void isIn​(java.util.Collection<T> values)  
      void isIn​(T... values)  
      void isNull()  
      ObjectChecker<T> not()
      Makes checker negative.
      void not​(org.hamcrest.Matcher<? super T> matcher)
      Inverts the rule.
      void not​(T value)  
      void notNull()  
      void same​(T object)
      Creates a new instance of IsSame
      void satisfies​(com.google.common.base.Predicate<? super T> predicate)  
      (package private) static java.lang.StackTraceElement[] trimStackTrace​(java.lang.StackTraceElement[] stackTrace)  
      (package private) static void verifyCheck​(java.lang.String description, boolean assertionState)  
      protected void verifyUsingMatcher​(org.hamcrest.Matcher<? super T> matcher)  
      (package private) static <Z> void verifyUsingMatcher​(Z actualValue, org.hamcrest.Matcher<? super Z> matcher)  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • actualValue

        @Nullable
        final T actualValue
      • negate

        final boolean negate
    • Constructor Detail

      • ObjectChecker

        ObjectChecker​(@Nullable
                      T actualValue,
                      boolean negate)
    • Method Detail

      • fail

        static void fail​(@Nullable
                         java.lang.Object actualValue,
                         org.hamcrest.Matcher<?> matcher)
      • trimStackTrace

        static java.lang.StackTraceElement[] trimStackTrace​(java.lang.StackTraceElement[] stackTrace)
      • verifyCheck

        static void verifyCheck​(java.lang.String description,
                                boolean assertionState)
      • verifyUsingMatcher

        static <Z> void verifyUsingMatcher​(@Nullable
                                           Z actualValue,
                                           org.hamcrest.Matcher<? super Z> matcher)
      • equals

        @Deprecated
        public boolean equals​(java.lang.Object any)
        Deprecated.
        You probably want to use is(Object) method for matcher wrapper.
        Deprecated to prevent accidental usage of this method.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        any - object
        Returns:
        nothing
      • allOf

        @SafeVarargs
        public final void allOf​(org.hamcrest.Matcher<? super T>... matchers)
        Evaluates to true only if ALL of the passed in matchers evaluate to true.
        Parameters:
        matchers - the matchers
      • anyOf

        @SafeVarargs
        public final void anyOf​(org.hamcrest.Matcher<? super T>... matchers)
        Evaluates to true if ANY of the passed in matchers evaluate to true.
        Parameters:
        matchers - the matchers
      • anything

        public void anything()
        This matcher always evaluates to true.
      • hasToString

        public void hasToString​(java.lang.String expectedToStringValue)
      • is

        public void is​(org.hamcrest.Matcher<? super T> matcher)
      • is

        public void is​(@Nullable
                       T value)
        This is equal to check
        Parameters:
        value - the value
      • isA

        public void isA​(java.lang.Class<?> type)
        Is the value an instance of a particular type?.
        Parameters:
        type - the type
      • isNull

        public void isNull()
      • not

        public void not​(org.hamcrest.Matcher<? super T> matcher)
        Inverts the rule.
        Parameters:
        matcher - the matcher
      • not

        public ObjectChecker<T> not()
        Makes checker negative.
        Returns:
        negative checker
      • ensureNonNegative

        protected void ensureNonNegative()
      • not

        public void not​(@Nullable
                        T value)
      • notNull

        public void notNull()
      • same

        public void same​(T object)
        Creates a new instance of IsSame
        Parameters:
        object - The predicate evaluates to true only when the argument is this object.
      • isIn

        public void isIn​(java.util.Collection<T> values)
      • isIn

        @SafeVarargs
        public final void isIn​(T... values)
      • satisfies

        public void satisfies​(com.google.common.base.Predicate<? super T> predicate)
      • verifyUsingMatcher

        protected void verifyUsingMatcher​(org.hamcrest.Matcher<? super T> matcher)
      • hashCode

        @Deprecated
        public int hashCode()
        Deprecated.
        This class should not be used with collections
        Overrides:
        hashCode in class java.lang.Object