Class HashCodeAndEqualsSafeSet
java.lang.Object
org.mockito.internal.util.collections.HashCodeAndEqualsSafeSet
hashCode and equals safe hash based set.
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.
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
boolean
addAll
(Collection<?> mocks) private HashSet
<HashCodeAndEqualsMockWrapper> asWrappedMocks
(Collection<?> mocks) void
clear()
clone()
boolean
boolean
containsAll
(Collection<?> mocks) boolean
int
hashCode()
boolean
isEmpty()
iterator()
static HashCodeAndEqualsSafeSet
static HashCodeAndEqualsSafeSet
boolean
boolean
removeAll
(Collection<?> mocks) boolean
retainAll
(Collection<?> mocks) int
size()
Object[]
toArray()
<T> T[]
toArray
(T[] typedArray) toString()
private <T> T[]
unwrapTo
(T[] array) Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream
Methods inherited from interface java.util.Set
spliterator
-
Field Details
-
backingHashSet
-
-
Constructor Details
-
HashCodeAndEqualsSafeSet
public HashCodeAndEqualsSafeSet()
-
-
Method Details
-
iterator
-
size
public int size() -
isEmpty
public boolean isEmpty() -
contains
-
add
-
remove
-
clear
public void clear() -
clone
- Overrides:
clone
in classObject
- Throws:
CloneNotSupportedException
-
equals
-
hashCode
public int hashCode() -
toArray
-
toArray
public <T> T[] toArray(T[] typedArray) -
unwrapTo
private <T> T[] unwrapTo(T[] array) -
removeAll
-
containsAll
- Specified by:
containsAll
in interfaceCollection<Object>
- Specified by:
containsAll
in interfaceSet<Object>
-
addAll
-
retainAll
-
asWrappedMocks
-
toString
-
of
-
of
-