Top Description Fields Constructors Methods
org.assertj.core.internal

public Class StandardComparisonStrategy

extends AbstractComparisonStrategy
Class Inheritance
Known Direct Subclasses
org.assertj.core.internal.AtomicReferenceArrayElementComparisonStrategy, org.assertj.core.internal.IterableElementComparisonStrategy, org.assertj.core.internal.ObjectArrayElementComparisonStrategy
Static Imports
org.assertj.core.util.Preconditions.checkArgument

Implements ComparisonStrategy contract with a comparison strategy based on java.util.Objects#deepEquals(Object, Object) method, it is also based on Comparable#compareTo(Object) when Object are Comparable method.
Author
Joel Costigliola

Field Summary

Modifier and TypeField and Description
private static final StandardComparisonStrategy

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if the arguments are deeply equal to each other, false otherwise
areEqual
(Object
the object to compare to other
actual
,
Object
the object to compare to actual
other
)

Implements org.assertj.core.internal.ComparisonStrategy.areEqual.

Returns true if the arguments are deeply equal to each other, false otherwise.
private void
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
)

Overrides org.assertj.core.internal.AbstractComparisonStrategy.duplicatesFrom.

Implements org.assertj.core.internal.ComparisonStrategy.duplicatesFrom.

Returns any duplicate elements from the given collection according to java.util.Objects#deepEquals(Object, Object) comparison strategy.
public static StandardComparisonStrategy

Returns:

the singleton instance of this class.
instance
()

Returns the singleton instance of this class.

public boolean
isGreaterThan(Object
the object to compare to other
actual
,
Object
the object to compare to actual
other
)

Implements org.assertj.core.internal.ComparisonStrategy.isGreaterThan.

Returns true if actual is greater than other, false otherwise.
public boolean
isLessThan(Object
the object to compare to other
actual
,
Object
the object to compare to actual
other
)

Overrides org.assertj.core.internal.AbstractComparisonStrategy.isLessThan.

Implements org.assertj.core.internal.ComparisonStrategy.isLessThan.

Returns true if actual is less than other, false otherwise.
public boolean
isStandard()

Overrides org.assertj.core.internal.AbstractComparisonStrategy.isStandard.

Implements org.assertj.core.internal.ComparisonStrategy.isStandard.

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

Returns:

true if given Iterable contains given value based on java.util.Objects#deepEquals(Object, Object), false otherwise.
iterableContains
(Iterable<?>
the Iterable to search value in
iterable
,
Object
the object to look for in given Iterable
value
)

Implements org.assertj.core.internal.ComparisonStrategy.iterableContains.

Returns true if given Iterable contains given value based on java.util.Objects#deepEquals(Object, Object), false otherwise.
public void
iterableRemoves(Iterable<?>
the Iterable we want remove value from
iterable
,
Object
object to remove from given Iterable
value
)

Implements org.assertj.core.internal.ComparisonStrategy.iterableRemoves.

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
)

Implements org.assertj.core.internal.ComparisonStrategy.iterablesRemoveFirst.

Removes the first value in iterable that matches the value according to the implemented comparison strategy.
protected Set<Object>
public boolean
stringContains(String
the string to search sequence in (must not be null)
string
,
String
the String to look for in given string
sequence
)

Implements org.assertj.core.internal.ComparisonStrategy.stringContains.

Returns true if given string contains given sequence according to the implemented comparison strategy, false otherwise.
public boolean
stringEndsWith(String
the String we want to look starting suffix
string
,
String
the suffix String to look for at string's end
suffix
)

Implements org.assertj.core.internal.ComparisonStrategy.stringEndsWith.

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

Implements org.assertj.core.internal.ComparisonStrategy.stringStartsWith.

Returns true if string starts with prefix according to the implemented comparison strategy, false otherwise.
Inherited from org.assertj.core.internal.AbstractComparisonStrategy:
arrayContainsisGreaterThanOrEqualToisLessThanOrEqualTo

Field Detail

INSTANCEback to summary
private static final StandardComparisonStrategy INSTANCE

Constructor Detail

StandardComparisonStrategyback to summary
protected StandardComparisonStrategy()

Creates a new StandardComparisonStrategy, comparison strategy being based on java.util.Objects#deepEquals(Object, Object).

Method Detail

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

Implements org.assertj.core.internal.ComparisonStrategy.areEqual.

Returns true if the arguments are deeply equal to each other, false otherwise.

It mimics the behavior of java.util.Objects#deepEquals(Object, Object), but without performing a reference check between the two arguments. According to deepEquals javadoc, the reference check should be delegated to the equals method of the first argument, but this is not happening. Bug JDK-8196069 also mentions this gap.

Parameters
actual:Object

the object to compare to other

other:Object

the object to compare to actual

Returns:boolean

true if the arguments are deeply equal to each other, false otherwise

Annotations
@Override
See Also
JDK-8196069
checkArgumentIsComparableback to summary
private void checkArgumentIsComparable(Object actual)
duplicatesFromback to summary
public Iterable<?> duplicatesFrom(Iterable<?> iterable)

Overrides org.assertj.core.internal.AbstractComparisonStrategy.duplicatesFrom.

Implements org.assertj.core.internal.ComparisonStrategy.duplicatesFrom.

Returns any duplicate elements from the given collection according to java.util.Objects#deepEquals(Object, Object) 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.

Annotations
@Override
instanceback to summary
public static StandardComparisonStrategy instance()

Returns the singleton instance of this class.

Returns:StandardComparisonStrategy

the singleton instance of this class.

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

Implements org.assertj.core.internal.ComparisonStrategy.isGreaterThan.

Doc from org.assertj.core.internal.ComparisonStrategy.isGreaterThan.

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.

Annotations
@SuppressWarnings:rawtypes, unchecked
@Override
isLessThanback to summary
public boolean isLessThan(Object actual, Object other)

Overrides org.assertj.core.internal.AbstractComparisonStrategy.isLessThan.

Implements org.assertj.core.internal.ComparisonStrategy.isLessThan.

Doc from org.assertj.core.internal.ComparisonStrategy.isLessThan.

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.

Annotations
@SuppressWarnings:rawtypes, unchecked
@Override
isStandardback to summary
public boolean isStandard()

Overrides org.assertj.core.internal.AbstractComparisonStrategy.isStandard.

Implements org.assertj.core.internal.ComparisonStrategy.isStandard.

Doc from org.assertj.core.internal.ComparisonStrategy.isStandard.

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

Returns:boolean

true if comparison strategy is default/standard, false otherwise

Annotations
@Override
iterableContainsback to summary
public boolean iterableContains(Iterable<?> iterable, Object value)

Implements org.assertj.core.internal.ComparisonStrategy.iterableContains.

Returns true if given Iterable contains given value based on java.util.Objects#deepEquals(Object, Object), false otherwise.
If given Iterable is null, return false.

Parameters
iterable: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 based on java.util.Objects#deepEquals(Object, Object), false otherwise.

Annotations
@Override
iterableRemovesback to summary
public void iterableRemoves(Iterable<?> iterable, Object value)

Implements org.assertj.core.internal.ComparisonStrategy.iterableRemoves.

Doc from org.assertj.core.internal.ComparisonStrategy.iterableRemoves.

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

Annotations
@Override
iterablesRemoveFirstback to summary
public void iterablesRemoveFirst(Iterable<?> iterable, Object value)

Implements org.assertj.core.internal.ComparisonStrategy.iterablesRemoveFirst.

Doc from org.assertj.core.internal.ComparisonStrategy.iterablesRemoveFirst.

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

Annotations
@Override
newSetUsingComparisonStrategyback to summary
protected Set<Object> newSetUsingComparisonStrategy()

Implements abstract org.assertj.core.internal.AbstractComparisonStrategy.newSetUsingComparisonStrategy.

Doc from org.assertj.core.internal.AbstractComparisonStrategy.newSetUsingComparisonStrategy.

Returns a Set honoring the comparison strategy used.

Returns:Set<Object>

a Set honoring the comparison strategy used.

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

Implements org.assertj.core.internal.ComparisonStrategy.stringContains.

Doc from org.assertj.core.internal.ComparisonStrategy.stringContains.

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.

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

Implements org.assertj.core.internal.ComparisonStrategy.stringEndsWith.

Doc from org.assertj.core.internal.ComparisonStrategy.stringEndsWith.

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.

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

Implements org.assertj.core.internal.ComparisonStrategy.stringStartsWith.

Doc from org.assertj.core.internal.ComparisonStrategy.stringStartsWith.

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.

Annotations
@Override