Package org.fest.assertions.internal
Class ComparatorBasedComparisonStrategy
java.lang.Object
org.fest.assertions.internal.AbstractComparisonStrategy
org.fest.assertions.internal.ComparatorBasedComparisonStrategy
- All Implemented Interfaces:
ComparisonStrategy
Implements
ComparisonStrategy contract with a comparison strategy based on a Comparator.- Author:
- Joel Costigliola
-
Constructor Summary
ConstructorsConstructorDescriptionComparatorBasedComparisonStrategy(Comparator comparator) Creates a newComparatorBasedComparisonStrategyspecifying the comparison strategy with given comparator. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns true if actual and other are equal according tocomparator, false otherwise.
Handles the cases where one of the parameter is null so that internalcomparatordoes not have too.Iterable<?>duplicatesFrom(Iterable<?> iterable) Returns any duplicate elements from the givenIterableaccording tocomparator.Comparator<?>booleanisGreaterThan(Object actual, Object other) Returns true if actual is greater than other, false otherwise.booleaniterableContains(Iterable<?> iterable, Object value) voiditerableRemoves(Iterable<?> iterable, Object value) Look for given value in givenIterableaccording to theComparator, if value is found it is removed from it.
Does nothing if givenIterableis null (meaning no exception thrown).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 sstring 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.toString()Methods inherited from class org.fest.assertions.internal.AbstractComparisonStrategy
arrayContains, isGreaterThanOrEqualTo, isLessThan, isLessThanOrEqualTo
-
Constructor Details
-
ComparatorBasedComparisonStrategy
Creates a newComparatorBasedComparisonStrategyspecifying the comparison strategy with given comparator.- Parameters:
comparator- the comparison strategy to use.
-
-
Method Details
-
iterableContains
-
iterableRemoves
Look for given value in givenIterableaccording to theComparator, if value is found it is removed from it.
Does nothing if givenIterableis null (meaning no exception thrown). -
areEqual
Returns true if actual and other are equal according tocomparator, false otherwise.
Handles the cases where one of the parameter is null so that internalcomparatordoes not have too.- Parameters:
actual- the object to compare to otherother- the object to compare to actual- Returns:
- true if actual and other are equal according to
comparator, false otherwise.
-
duplicatesFrom
Returns any duplicate elements from the givenIterableaccording tocomparator.- 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.
-
toString
-
getComparator
-
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 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: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.
-