Package org.fest.assertions.internal
Class StandardComparisonStrategy
- java.lang.Object
-
- org.fest.assertions.internal.AbstractComparisonStrategy
-
- org.fest.assertions.internal.StandardComparisonStrategy
-
- All Implemented Interfaces:
ComparisonStrategy
public class StandardComparisonStrategy extends AbstractComparisonStrategy
ImplementsComparisonStrategycontract with a comparison strategy based onObject.equals(Object)method, it is also based onComparable.compareTo(Object)when Object areComparablemethod.- Author:
- Joel Costigliola
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanareEqual(java.lang.Object actual, java.lang.Object other)Returns true if actual and other are equal based onObject.equals(Object), false otherwise.java.lang.Iterable<?>duplicatesFrom(java.lang.Iterable<?> iterable)Returns any duplicate elements from the given collection according toObject.equals(Object)comparison strategy.static StandardComparisonStrategyinstance()Returns the singleton instance of this class.booleanisGreaterThan(java.lang.Object actual, java.lang.Object other)Returns true if actual is greater than other, false otherwise.booleaniterableContains(java.lang.Iterable<?> iterable, java.lang.Object value)Returns true if givenIterablecontains given value based onObject.equals(Object), false otherwise.
If givenIterableis null, return false.voiditerableRemoves(java.lang.Iterable<?> iterable, java.lang.Object value)Look for given value in givenIterableaccording to the implemented comparison strategy, if value is found it is removed from it.
If givenIterableis null, does nothing.booleanstringContains(java.lang.String string, java.lang.String sequence)Returns true if given string contains given sequence according to the implemented comparison strategy, false otherwise.booleanstringEndsWith(java.lang.String string, java.lang.String suffix)Returns true if sstring ends with suffix according to the implemented comparison strategy, false otherwise.booleanstringStartsWith(java.lang.String string, java.lang.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 Detail
-
instance
public static StandardComparisonStrategy instance()
Returns the singleton instance of this class.- Returns:
- the singleton instance of this class.
-
areEqual
public boolean areEqual(java.lang.Object actual, java.lang.Object other)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
public boolean iterableContains(java.lang.Iterable<?> iterable, java.lang.Object value)Returns true if givenIterablecontains given value based onObject.equals(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 onObject.equals(Object), false otherwise.
-
iterableRemoves
public void iterableRemoves(java.lang.Iterable<?> iterable, java.lang.Object value)Look for given value in givenIterableaccording to the implemented comparison strategy, if value is found it is removed from it.
If givenIterableis null, does nothing.- Parameters:
iterable- theIterablewe want remove value fromvalue- object to remove from givenIterable
-
duplicatesFrom
public java.lang.Iterable<?> duplicatesFrom(java.lang.Iterable<?> iterable)
Returns any duplicate elements from the given collection according toObject.equals(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
public boolean stringStartsWith(java.lang.String string, java.lang.String prefix)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
public boolean stringEndsWith(java.lang.String string, java.lang.String suffix)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
public boolean stringContains(java.lang.String string, java.lang.String sequence)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
public boolean isGreaterThan(java.lang.Object actual, java.lang.Object other)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.
-
-