Package org.cactoos.collection
Class NoNulls<X>
- java.lang.Object
-
- org.cactoos.collection.NoNulls<X>
-
- Type Parameters:
X
- Element type
- All Implemented Interfaces:
Iterable<X>
,Collection<X>
public final class NoNulls<X> extends Object implements Collection<X>
A decorator ofCollection
that tolerates no NULLs.There is no thread-safety guarantee.
- Since:
- 0.27
-
-
Constructor Summary
Constructors Constructor Description NoNulls(Collection<X> items)
Ctor without '? extends X' wildcard because of the issue: The client gets Collection of X The client adds item of X to it The client queries items of original Collection of ? extends X Runtime exception occurs
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(X item)
boolean
addAll(Collection<? extends X> items)
void
clear()
boolean
contains(Object item)
boolean
containsAll(Collection<?> items)
boolean
equals(Object obj)
int
hashCode()
boolean
isEmpty()
Iterator<X>
iterator()
boolean
remove(Object item)
boolean
removeAll(Collection<?> items)
boolean
retainAll(Collection<?> items)
int
size()
Object[]
toArray()
<T> T[]
toArray(T[] array)
String
toString()
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, spliterator, stream, toArray
-
-
-
-
Constructor Detail
-
NoNulls
public NoNulls(Collection<X> items)
Ctor without '? extends X' wildcard because of the issue:- The client gets Collection of X
- The client adds item of X to it
- The client queries items of original Collection of ? extends X
- Runtime exception occurs
- Parameters:
items
- Original one.
-
-
Method Detail
-
size
public int size()
- Specified by:
size
in interfaceCollection<X>
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty
in interfaceCollection<X>
-
contains
public boolean contains(Object item)
- Specified by:
contains
in interfaceCollection<X>
-
toArray
public Object[] toArray()
- Specified by:
toArray
in interfaceCollection<X>
-
toArray
public <T> T[] toArray(T[] array)
- Specified by:
toArray
in interfaceCollection<X>
-
add
public boolean add(X item)
- Specified by:
add
in interfaceCollection<X>
-
remove
public boolean remove(Object item)
- Specified by:
remove
in interfaceCollection<X>
-
containsAll
public boolean containsAll(Collection<?> items)
- Specified by:
containsAll
in interfaceCollection<X>
-
addAll
public boolean addAll(Collection<? extends X> items)
- Specified by:
addAll
in interfaceCollection<X>
-
removeAll
public boolean removeAll(Collection<?> items)
- Specified by:
removeAll
in interfaceCollection<X>
-
retainAll
public boolean retainAll(Collection<?> items)
- Specified by:
retainAll
in interfaceCollection<X>
-
clear
public void clear()
- Specified by:
clear
in interfaceCollection<X>
-
equals
public boolean equals(Object obj)
- Specified by:
equals
in interfaceCollection<X>
- Overrides:
equals
in classObject
-
hashCode
public int hashCode()
- Specified by:
hashCode
in interfaceCollection<X>
- Overrides:
hashCode
in classObject
-
-