Package org.fest.assertions.internal
Class StandardComparisonStrategy
java.lang.Object
org.fest.assertions.internal.AbstractComparisonStrategy
org.fest.assertions.internal.StandardComparisonStrategy
- All Implemented Interfaces:
ComparisonStrategy
Implements
ComparisonStrategy
contract with a comparison strategy based on Object.equals(Object)
method, it is
also based on Comparable.compareTo(Object)
when Object are Comparable
method.- Author:
- Joel Costigliola
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns true if actual and other are equal based onObject.equals(Object)
, false otherwise.Iterable
<?> duplicatesFrom
(Iterable<?> iterable) Returns any duplicate elements from the given collection according toObject.equals(Object)
comparison strategy.static StandardComparisonStrategy
instance()
Returns the singleton instance of this class.boolean
isGreaterThan
(Object actual, Object other) Returns true if actual is greater than other, false otherwise.boolean
iterableContains
(Iterable<?> iterable, Object value) Returns true if givenIterable
contains given value based onObject.equals(Object)
, false otherwise.
If givenIterable
is null, return false.void
iterableRemoves
(Iterable<?> iterable, Object value) 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 sstring 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.Methods inherited from class org.fest.assertions.internal.AbstractComparisonStrategy
arrayContains, isGreaterThanOrEqualTo, isLessThan, isLessThanOrEqualTo
-
Method Details
-
instance
Returns the singleton instance of this class.- Returns:
- the singleton instance of this class.
-
areEqual
Returns true if actual and other are equal based onObject.equals(Object)
, false otherwise.- Parameters:
actual
- the object to compare to otherother
- the object to compare to actual- Returns:
- true if actual and other are equal based on
Object.equals(Object)
, false otherwise.
-
iterableContains
Returns true if givenIterable
contains given value based onObject.equals(Object)
, false otherwise.
If givenIterable
is null, return false.- Parameters:
iterable
- theIterable
to search value invalue
- the object to look for in givenIterable
- Returns:
- true if given
Iterable
contains given value based onObject.equals(Object)
, false otherwise.
-
iterableRemoves
-
duplicatesFrom
Returns any duplicate elements from the given collection according toObject.equals(Object)
comparison strategy.- Specified by:
duplicatesFrom
in interfaceComparisonStrategy
- Overrides:
duplicatesFrom
in classAbstractComparisonStrategy
- Parameters:
iterable
- the givenIterable
we want to extract duplicate elements.- Returns:
- an
Iterable
containing the duplicate elements of the given one. If no duplicates are found, an emptyIterable
is returned.
-
stringStartsWith
Description copied from interface:ComparisonStrategy
Returns true if string starts with prefix according to the implemented comparison strategy, false otherwise.- Parameters:
string
- the String we want to look starting prefixprefix
- 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
Description copied from interface:ComparisonStrategy
Returns true if sstring ends with suffix according to the implemented comparison strategy, false otherwise.- Parameters:
string
- the String we want to look starting suffixsuffix
- 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.
-
stringContains
Description copied from interface:ComparisonStrategy
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.
-
isGreaterThan
Description copied from interface:ComparisonStrategy
Returns true if actual is greater than other, false otherwise.- Parameters:
actual
- the object to compare to otherother
- the object to compare to actual- Returns:
- true if actual is greater than other, false otherwise.
-