Top Description Methods
org.assertj.core.internal

public Interface ComparisonStrategy

Known Direct Implementers
org.assertj.core.internal.AbstractComparisonStrategy

Describes the contract to implement a consistent comparison strategy that covers :
- comparing two objects for equality and order
- knowing if an object belongs to a group of objects (collection/array)
- determining duplicates in a group of objects (collection/array)
- string specific comparison
Author
Joel Costigliola

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if actual and other are equal according to the underlying comparison strategy.
areEqual
(Object
the object to compare to other
actual
,
Object
the object to compare to actual
other
)

Returns true if actual and other are equal according to the implemented comparison strategy.

public boolean

Returns:

true if given array contains given value according to the implemented comparison strategy, false otherwise.
arrayContains
(Object
the array to search value in (must not be null)
array
,
Object
the object to look for in given array
value
)

Returns true if given array contains given value according to the implemented comparison strategy, false otherwise.

public default String

Returns:

the comparison strategy description used in error messages.
asText
()

Used in error messages when a custom comparison strategy was used to compare values.

public Iterable<?>

Returns:

an Iterable containing the duplicate elements of the given one. If no duplicates are found, an empty Iterable is returned.
duplicatesFrom
(Iterable<?>
the given Iterable we want to extract duplicate elements.
iterable
)

Returns any duplicate elements from the given Iterable according to the implemented comparison strategy.

public boolean

Returns:

true if actual is greater than other, false otherwise.
isGreaterThan
(Object
the object to compare to other
actual
,
Object
the object to compare to actual
other
)

Returns true if actual is greater than other, false otherwise.

public boolean

Returns:

true if actual is greater than or equal to other, false otherwise.
isGreaterThanOrEqualTo
(Object
the object to compare to other
actual
,
Object
the object to compare to actual
other
)

Returns true if actual is greater than or equal to other, false otherwise.

public boolean

Returns:

true if actual is less than other, false otherwise.
isLessThan
(Object
the object to compare to other
actual
,
Object
the object to compare to actual
other
)

Returns true if actual is less than other, false otherwise.

public boolean

Returns:

true if actual is less than or equal to other, false otherwise.
isLessThanOrEqualTo
(Object
the object to compare to other
actual
,
Object
the object to compare to actual
other
)

Returns true if actual is less than or equal to other, false otherwise.

public boolean

Returns:

true if comparison strategy is default/standard, false otherwise
isStandard
()

Return true if comparison strategy is default/standard, false otherwise

public boolean

Returns:

true if given Iterable contains given value according to the implemented comparison strategy, false otherwise.
iterableContains
(Iterable<?>
the Iterable to search value in
collection
,
Object
the object to look for in given Iterable
value
)

Returns true if given Iterable contains given value according to the implemented comparison strategy, false otherwise.

public void
iterableRemoves(Iterable<?>
the Iterable we want remove value from
iterable
,
Object
object to remove from given Iterable
value
)

Look for given value in given Iterable according to the implemented comparison strategy, if value is found it is removed from it.

public void
iterablesRemoveFirst(Iterable<?>
the Iterable we want remove value from
iterable
,
Object
object to remove from given Iterable
value
)

Removes the first value in iterable that matches the value according to the implemented comparison strategy.

public boolean

Returns:

true if given string contains given sequence according to the implemented comparison strategy, false otherwise.
stringContains
(String
the string to search sequence in (must not be null)
string
,
String
the String to look for in given string
sequence
)

Returns true if given string contains given sequence according to the implemented comparison strategy, false otherwise.

public boolean

Returns:

true if string ends with suffix according to the implemented comparison strategy, false otherwise.
stringEndsWith
(String
the String we want to look starting suffix
string
,
String
the suffix String to look for at string's end
suffix
)

Returns true if string ends with suffix according to the implemented comparison strategy, false otherwise.

public boolean

Returns:

true if string starts with prefix according to the implemented comparison strategy, false otherwise.
stringStartsWith
(String
the String we want to look starting prefix
string
,
String
the prefix String to look for at string's start
prefix
)

Returns true if string starts with prefix according to the implemented comparison strategy, false otherwise.

Method Detail

areEqualback to summary
public boolean areEqual(Object actual, Object other)

Returns true if actual and other are equal according to the implemented comparison strategy.

Parameters
actual:Object

the object to compare to other

other:Object

the object to compare to actual

Returns:boolean

true if actual and other are equal according to the underlying comparison strategy.

arrayContainsback to summary
public boolean arrayContains(Object array, Object value)

Returns true if given array contains given value according to the implemented comparison strategy, false otherwise.

Parameters
array:Object

the array to search value in (must not be null)

value:Object

the object to look for in given array

Returns:boolean

true if given array contains given value according to the implemented comparison strategy, false otherwise.

asTextback to summary
public default String asText()

Used in error messages when a custom comparison strategy was used to compare values.

For example ComparatorBasedComparisonStrategy returns:

"when comparing values using " + toString()
Returns:String

the comparison strategy description used in error messages.

duplicatesFromback to summary
public Iterable<?> duplicatesFrom(Iterable<?> iterable)

Returns any duplicate elements from the given Iterable according to the implemented comparison strategy.

Parameters
iterable:Iterable<?>

the given Iterable we want to extract duplicate elements.

Returns:Iterable<?>

an Iterable containing the duplicate elements of the given one. If no duplicates are found, an empty Iterable is returned.

isGreaterThanback to summary
public boolean isGreaterThan(Object actual, Object other)

Returns true if actual is greater than other, false otherwise.

Parameters
actual:Object

the object to compare to other

other:Object

the object to compare to actual

Returns:boolean

true if actual is greater than other, false otherwise.

Exceptions
UnsupportedOperationException:
if operation is not supported by a concrete implementation.
isGreaterThanOrEqualToback to summary
public boolean isGreaterThanOrEqualTo(Object actual, Object other)

Returns true if actual is greater than or equal to other, false otherwise.

Parameters
actual:Object

the object to compare to other

other:Object

the object to compare to actual

Returns:boolean

true if actual is greater than or equal to other, false otherwise.

Exceptions
UnsupportedOperationException:
if operation is not supported by a concrete implementation.
isLessThanback to summary
public boolean isLessThan(Object actual, Object other)

Returns true if actual is less than other, false otherwise.

Parameters
actual:Object

the object to compare to other

other:Object

the object to compare to actual

Returns:boolean

true if actual is less than other, false otherwise.

Exceptions
UnsupportedOperationException:
if operation is not supported by a concrete implementation.
isLessThanOrEqualToback to summary
public boolean isLessThanOrEqualTo(Object actual, Object other)

Returns true if actual is less than or equal to other, false otherwise.

Parameters
actual:Object

the object to compare to other

other:Object

the object to compare to actual

Returns:boolean

true if actual is less than or equal to other, false otherwise.

Exceptions
UnsupportedOperationException:
if operation is not supported by a concrete implementation.
isStandardback to summary
public boolean isStandard()

Return true if comparison strategy is default/standard, false otherwise

Returns:boolean

true if comparison strategy is default/standard, false otherwise

iterableContainsback to summary
public 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:Iterable<?>

the Iterable to search value in

value:Object

the object to look for in given Iterable

Returns:boolean

true if given Iterable contains given value according to the implemented comparison strategy, false otherwise.

iterableRemovesback to summary
public 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:Iterable<?>

the Iterable we want remove value from

value:Object

object to remove from given Iterable

iterablesRemoveFirstback to summary
public 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:Iterable<?>

the Iterable we want remove value from

value:Object

object to remove from given Iterable

stringContainsback to summary
public boolean stringContains(String string, String sequence)

Returns true if given string contains given sequence according to the implemented comparison strategy, false otherwise.

Parameters
string:String

the string to search sequence in (must not be null)

sequence:String

the String to look for in given string

Returns:boolean

true if given string contains given sequence according to the implemented comparison strategy, false otherwise.

stringEndsWithback to summary
public boolean stringEndsWith(String string, String suffix)

Returns true if string ends with suffix according to the implemented comparison strategy, false otherwise.

Parameters
string:String

the String we want to look starting suffix

suffix:String

the suffix String to look for at string's end

Returns:boolean

true if string ends with suffix according to the implemented comparison strategy, false otherwise.

stringStartsWithback to summary
public boolean stringStartsWith(String string, String prefix)

Returns true if string starts with prefix according to the implemented comparison strategy, false otherwise.

Parameters
string:String

the String we want to look starting prefix

prefix:String

the prefix String to look for at string's start

Returns:boolean

true if string starts with prefix according to the implemented comparison strategy, false otherwise.