Class Conditions


  • public class Conditions
    extends Object
    Verifies that a value satisfies a Condition.
    Author:
    Alex Ruiz
    • Constructor Detail

      • Conditions

        Conditions()
    • Method Detail

      • instance

        public static Conditions instance()
        Returns the singleton instance of this class.
        Returns:
        the singleton instance of this class.
      • assertIs

        public <T> void assertIs​(AssertionInfo info,
                                 T actual,
                                 Condition<? super T> condition)
        Asserts that the actual value satisfies the given Condition.
        Type Parameters:
        T - the type of the actual value and the type of values that given Condition takes.
        Parameters:
        info - contains information about the assertion.
        actual - the actual value.
        condition - the given Condition.
        Throws:
        NullPointerException - if the given Condition is null.
        AssertionError - if the actual value does not satisfy the given Condition.
      • assertIsNot

        public <T> void assertIsNot​(AssertionInfo info,
                                    T actual,
                                    Condition<? super T> condition)
        Asserts that the actual value does not satisfy the given Condition.
        Type Parameters:
        T - the type of the actual value and the type of values that given Condition takes.
        Parameters:
        info - contains information about the assertion.
        actual - the actual value.
        condition - the given Condition.
        Throws:
        NullPointerException - if the given Condition is null.
        AssertionError - if the actual value satisfies the given Condition.
      • assertHas

        public <T> void assertHas​(AssertionInfo info,
                                  T actual,
                                  Condition<? super T> condition)
        Asserts that the actual value satisfies the given Condition.
        Type Parameters:
        T - the type of the actual value and the type of values that given Condition takes.
        Parameters:
        info - contains information about the assertion.
        actual - the actual value.
        condition - the given Condition.
        Throws:
        NullPointerException - if the given Condition is null.
        AssertionError - if the actual value does not satisfy the given Condition.
      • assertDoesNotHave

        public <T> void assertDoesNotHave​(AssertionInfo info,
                                          T actual,
                                          Condition<? super T> condition)
        Asserts that the actual value does not satisfy the given Condition.
        Type Parameters:
        T - the type of the actual value and the type of values that given Condition takes.
        Parameters:
        info - contains information about the assertion.
        actual - the actual value.
        condition - the given Condition.
        Throws:
        NullPointerException - if the given Condition is null.
        AssertionError - if the actual value satisfies the given Condition.
      • assertSatisfies

        public <T> void assertSatisfies​(AssertionInfo info,
                                        T actual,
                                        Condition<? super T> condition)
      • assertIsNotNull

        public void assertIsNotNull​(Condition<?> condition)
        Asserts the given Condition is not null.
        Parameters:
        condition - the given Condition.
        Throws:
        NullPointerException - if the given Condition is null.