public class HashCodeAndEqualsSafeSet extends Object implements Set<Object>
Useful for holding mocks that have un-stubbable hashCode or equals method,
meaning that in this scenario the real code is always called and will most probably
cause an NullPointerException
.
This collection wraps the mock in an augmented type HashCodeAndEqualsMockWrapper
that have his own implementation.
HashCodeAndEqualsMockWrapper
Constructor and Description |
---|
HashCodeAndEqualsSafeSet() |
Modifier and Type | Method and Description |
---|---|
boolean |
add(Object mock) |
boolean |
addAll(Collection<?> mocks) |
void |
clear() |
Object |
clone() |
boolean |
contains(Object mock) |
boolean |
containsAll(Collection<?> mocks) |
boolean |
equals(Object o) |
int |
hashCode() |
boolean |
isEmpty() |
Iterator<Object> |
iterator() |
static HashCodeAndEqualsSafeSet |
of(Iterable<Object> objects) |
static HashCodeAndEqualsSafeSet |
of(Object... mocks) |
boolean |
remove(Object mock) |
boolean |
removeAll(Collection<?> mocks) |
boolean |
retainAll(Collection<?> mocks) |
int |
size() |
Object[] |
toArray() |
<T> T[] |
toArray(T[] typedArray) |
String |
toString() |
public int size()
public boolean isEmpty()
public boolean contains(Object mock)
public boolean add(Object mock)
public boolean remove(Object mock)
public void clear()
public Object clone() throws CloneNotSupportedException
clone
in class Object
CloneNotSupportedException
public boolean equals(Object o)
public int hashCode()
public Object[] toArray()
public <T> T[] toArray(T[] typedArray)
public boolean removeAll(Collection<?> mocks)
public boolean containsAll(Collection<?> mocks)
containsAll
in interface Collection<Object>
containsAll
in interface Set<Object>
public boolean addAll(Collection<?> mocks)
public boolean retainAll(Collection<?> mocks)
public static HashCodeAndEqualsSafeSet of(Object... mocks)
public static HashCodeAndEqualsSafeSet of(Iterable<Object> objects)
Mockito, MIT License