Interface ComparisonStrategy

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      boolean areEqual​(Object actual, Object other)
      Returns true if actual and other are equal according to the implemented comparison strategy.
      boolean arrayContains​(Object array, Object value)
      Returns true if given array contains given value according to the implemented comparison strategy, false otherwise.
      Iterable<?> duplicatesFrom​(Iterable<?> iterable)
      Returns any duplicate elements from the given Iterable according to the implemented comparison strategy.
      boolean isGreaterThan​(Object actual, Object other)
      Returns true if actual is greater than other, false otherwise.
      boolean isGreaterThanOrEqualTo​(Object actual, Object other)
      Returns true if actual is greater than or equal to other, false otherwise.
      boolean isLessThan​(Object actual, Object other)
      Returns true if actual is less than other, false otherwise.
      boolean isLessThanOrEqualTo​(Object actual, Object other)
      Returns true if actual is less than or equal to other, false otherwise.
      boolean isStandard()
      Return true if comparison strategy is default/standard, false otherwise
      boolean iterableContains​(Iterable<?> collection, Object value)
      Returns true if given Iterable contains given value according to the implemented comparison strategy, false otherwise.
      If given Iterable is null, return false.
      void iterableRemoves​(Iterable<?> iterable, Object value)
      Look for given value in given Iterable according to the implemented comparison strategy, if value is found it is removed from it.
      If given Iterable is null, does nothing.
      void iterablesRemoveFirst​(Iterable<?> iterable, Object value)
      Removes the first value in iterable that matches the value according to the implemented comparison strategy.
      boolean stringContains​(String string, String sequence)
      Returns true if given string contains given sequence according to the implemented comparison strategy, false otherwise.
      boolean stringEndsWith​(String string, String suffix)
      Returns true if string ends with suffix according to the implemented comparison strategy, false otherwise.
      boolean stringStartsWith​(String string, String prefix)
      Returns true if string starts with prefix according to the implemented comparison strategy, false otherwise.
    • Method Detail

      • areEqual

        boolean areEqual​(Object actual,
                         Object other)
        Returns true if actual and other are equal according to the implemented comparison strategy.
        Parameters:
        actual - the object to compare to other
        other - the object to compare to actual
        Returns:
        true if actual and other are equal according to the underlying comparison strategy.
      • isGreaterThan

        boolean isGreaterThan​(Object actual,
                              Object other)
        Returns true if actual is greater than other, false otherwise.
        Parameters:
        actual - the object to compare to other
        other - the object to compare to actual
        Returns:
        true if actual is greater than other, false otherwise.
        Throws:
        UnsupportedOperationException - if operation is not supported by a concrete implementation.
      • isGreaterThanOrEqualTo

        boolean isGreaterThanOrEqualTo​(Object actual,
                                       Object other)
        Returns true if actual is greater than or equal to other, false otherwise.
        Parameters:
        actual - the object to compare to other
        other - the object to compare to actual
        Returns:
        true if actual is greater than or equal to other, false otherwise.
        Throws:
        UnsupportedOperationException - if operation is not supported by a concrete implementation.
      • isLessThan

        boolean isLessThan​(Object actual,
                           Object other)
        Returns true if actual is less than other, false otherwise.
        Parameters:
        actual - the object to compare to other
        other - the object to compare to actual
        Returns:
        true if actual is less than other, false otherwise.
        Throws:
        UnsupportedOperationException - if operation is not supported by a concrete implementation.
      • isLessThanOrEqualTo

        boolean isLessThanOrEqualTo​(Object actual,
                                    Object other)
        Returns true if actual is less than or equal to other, false otherwise.
        Parameters:
        actual - the object to compare to other
        other - the object to compare to actual
        Returns:
        true if actual is less than or equal to other, false otherwise.
        Throws:
        UnsupportedOperationException - if operation is not supported by a concrete implementation.
      • iterableContains

        boolean iterableContains​(Iterable<?> collection,
                                 Object value)
        Returns true if given Iterable contains given value according to the implemented comparison strategy, false otherwise.
        If given Iterable is null, return false.
        Parameters:
        collection - the Iterable to search value in
        value - the object to look for in given Iterable
        Returns:
        true if given Iterable contains given value according to the implemented comparison strategy, false otherwise.
      • iterableRemoves

        void iterableRemoves​(Iterable<?> iterable,
                             Object value)
        Look for given value in given Iterable according to the implemented comparison strategy, if value is found it is removed from it.
        If given Iterable is null, does nothing.
        Parameters:
        iterable - the Iterable we want remove value from
        value - object to remove from given Iterable
      • iterablesRemoveFirst

        void iterablesRemoveFirst​(Iterable<?> iterable,
                                  Object value)
        Removes the first value in iterable that matches the value according to the implemented comparison strategy. If given Iterable is null, does nothing.
        Parameters:
        iterable - the Iterable we want remove value from
        value - object to remove from given Iterable
      • duplicatesFrom

        Iterable<?> duplicatesFrom​(Iterable<?> iterable)
        Returns any duplicate elements from the given Iterable according to the implemented comparison strategy.
        Parameters:
        iterable - the given Iterable we want to extract duplicate elements.
        Returns:
        an Iterable containing the duplicate elements of the given one. If no duplicates are found, an empty Iterable is returned.
      • arrayContains

        boolean arrayContains​(Object array,
                              Object value)
        Returns true if given array contains given value according to the implemented comparison strategy, false otherwise.
        Parameters:
        array - the array to search value in (must not be null)
        value - the object to look for in given array
        Returns:
        true if given array contains given value according to the implemented comparison strategy, false otherwise.
      • stringContains

        boolean stringContains​(String string,
                               String sequence)
        Returns true if given string contains given sequence according to the implemented comparison strategy, false otherwise.
        Parameters:
        string - the string to search sequence in (must not be null)
        sequence - the String to look for in given string
        Returns:
        true if given string contains given sequence according to the implemented comparison strategy, false otherwise.
      • stringStartsWith

        boolean stringStartsWith​(String string,
                                 String prefix)
        Returns true if string starts with prefix according to the implemented comparison strategy, false otherwise.
        Parameters:
        string - the String we want to look starting prefix
        prefix - the prefix String to look for at string's start
        Returns:
        true if string starts with prefix according to the implemented comparison strategy, false otherwise.
      • stringEndsWith

        boolean stringEndsWith​(String string,
                               String suffix)
        Returns true if string ends with suffix according to the implemented comparison strategy, false otherwise.
        Parameters:
        string - the String we want to look starting suffix
        suffix - the suffix String to look for at string's end
        Returns:
        true if string ends with suffix according to the implemented comparison strategy, false otherwise.
      • isStandard

        boolean isStandard()
        Return true if comparison strategy is default/standard, false otherwise
        Returns:
        true if comparison strategy is default/standard, false otherwise