Package org.assertj.core.internal
Class StandardComparisonStrategy
java.lang.Object
org.assertj.core.internal.AbstractComparisonStrategy
org.assertj.core.internal.StandardComparisonStrategy
- All Implemented Interfaces:
ComparisonStrategy
- Direct Known Subclasses:
AtomicReferenceArrayElementComparisonStrategy,IterableElementComparisonStrategy,ObjectArrayElementComparisonStrategy
Implements
ComparisonStrategy contract with a comparison strategy based on
Objects.deepEquals(Object, Object) method, it is also based on Comparable.compareTo(Object) when Object
are Comparable method.-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCreates a new, comparison strategy being based onStandardComparisonStrategyObjects.deepEquals(Object, Object). -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns true if actual and other are equal based onObjects.deepEquals(Object, Object), false otherwise.asText()private voidcheckArgumentIsComparable(Object actual) Iterable<?>duplicatesFrom(Iterable<?> iterable) Returns any duplicate elements from the given collection according toObjects.deepEquals(Object, Object)comparison strategy.static StandardComparisonStrategyinstance()Returns the singleton instance of this class.booleanisGreaterThan(Object actual, Object other) Returns true if actual is greater than other, false otherwise.booleanisLessThan(Object actual, Object other) Returns true if actual is less than other, false otherwise.booleanReturn true if comparison strategy is default/standard, false otherwisebooleaniterableContains(Iterable<?> iterable, Object value) Returns true if givenIterablecontains given value based onObjects.deepEquals(Object, Object), false otherwise.
If givenIterableis null, return false.voiditerableRemoves(Iterable<?> iterable, Object value) voiditerablesRemoveFirst(Iterable<?> iterable, Object value) Removes the first value initerablethat matches thevalueaccording to the implemented comparison strategy.Returns aSethonoring the comparison strategy used.booleanstringContains(String string, String sequence) Returns true if given string contains given sequence according to the implemented comparison strategy, false otherwise.booleanstringEndsWith(String string, String suffix) Returns true if string ends with suffix according to the implemented comparison strategy, false otherwise.booleanstringStartsWith(String string, String prefix) Returns true if string starts with prefix according to the implemented comparison strategy, false otherwise.Methods inherited from class org.assertj.core.internal.AbstractComparisonStrategy
arrayContains, isGreaterThanOrEqualTo, isLessThanOrEqualTo
-
Field Details
-
INSTANCE
-
-
Constructor Details
-
StandardComparisonStrategy
protected StandardComparisonStrategy()Creates a new, comparison strategy being based onStandardComparisonStrategyObjects.deepEquals(Object, Object).
-
-
Method Details
-
instance
Returns the singleton instance of this class.- Returns:
- the singleton instance of this class.
-
newSetUsingComparisonStrategy
Description copied from class:AbstractComparisonStrategyReturns aSethonoring the comparison strategy used.- Specified by:
newSetUsingComparisonStrategyin classAbstractComparisonStrategy- Returns:
- a
Sethonoring the comparison strategy used.
-
asText
- Specified by:
asTextin classAbstractComparisonStrategy
-
areEqual
Returns true if actual and other are equal based onObjects.deepEquals(Object, 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
Objects.deepEquals(Object, Object), false otherwise.
-
iterableContains
Returns true if givenIterablecontains given value based onObjects.deepEquals(Object, Object), false otherwise.
If givenIterableis null, return false.- Parameters:
iterable- theIterableto search value invalue- the object to look for in givenIterable- Returns:
- true if given
Iterablecontains given value based onObjects.deepEquals(Object, Object), false otherwise.
-
iterableRemoves
-
iterablesRemoveFirst
Removes the first value initerablethat matches thevalueaccording to the implemented comparison strategy. If givenIterableis null, does nothing. -
duplicatesFrom
Returns any duplicate elements from the given collection according toObjects.deepEquals(Object, Object)comparison strategy.- Specified by:
duplicatesFromin interfaceComparisonStrategy- Overrides:
duplicatesFromin classAbstractComparisonStrategy- Parameters:
iterable- the givenIterablewe want to extract duplicate elements.- Returns:
- an
Iterablecontaining the duplicate elements of the given one. If no duplicates are found, an emptyIterableis returned.
-
stringStartsWith
Description copied from interface:ComparisonStrategyReturns 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:ComparisonStrategyReturns true if string 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:ComparisonStrategyReturns 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:ComparisonStrategyReturns 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.
-
isLessThan
Description copied from interface:ComparisonStrategyReturns true if actual is less than other, false otherwise.- Specified by:
isLessThanin interfaceComparisonStrategy- Overrides:
isLessThanin classAbstractComparisonStrategy- Parameters:
actual- the object to compare to otherother- the object to compare to actual- Returns:
- true if actual is less than other, false otherwise.
-
checkArgumentIsComparable
-
isStandard
public boolean isStandard()Description copied from interface:ComparisonStrategyReturn true if comparison strategy is default/standard, false otherwise- Specified by:
isStandardin interfaceComparisonStrategy- Overrides:
isStandardin classAbstractComparisonStrategy- Returns:
- true if comparison strategy is default/standard, false otherwise
-