Package org.cactoos.collection
Class Immutable<X>
- java.lang.Object
-
- org.cactoos.collection.Immutable<X>
-
- Type Parameters:
X
- Type of source item
- All Implemented Interfaces:
Iterable<X>
,Collection<X>
public final class Immutable<X> extends Object implements Collection<X>
Decorator that doesn't allow any mutation of the wrappedCollection
.There is no thread-safety guarantee.
- Since:
- 1.16
-
-
Constructor Summary
Constructors Constructor Description Immutable(Collection<? extends X> src)
Ctor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(X item)
boolean
addAll(Collection<? extends X> list)
void
clear()
boolean
contains(Object object)
boolean
containsAll(Collection<?> list)
boolean
equals(Object obj)
int
hashCode()
boolean
isEmpty()
Iterator<X>
iterator()
boolean
remove(Object object)
boolean
removeAll(Collection<?> list)
boolean
retainAll(Collection<?> list)
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
-
Immutable
public Immutable(Collection<? extends X> src)
Ctor.- Parameters:
src
- Source collection
-
-
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 object)
- 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 object)
- Specified by:
remove
in interfaceCollection<X>
-
containsAll
public boolean containsAll(Collection<?> list)
- Specified by:
containsAll
in interfaceCollection<X>
-
addAll
public boolean addAll(Collection<? extends X> list)
- Specified by:
addAll
in interfaceCollection<X>
-
removeAll
public boolean removeAll(Collection<?> list)
- Specified by:
removeAll
in interfaceCollection<X>
-
retainAll
public boolean retainAll(Collection<?> list)
- Specified by:
retainAll
in interfaceCollection<X>
-
clear
public void clear()
- Specified by:
clear
in interfaceCollection<X>
-
hashCode
public int hashCode()
- Specified by:
hashCode
in interfaceCollection<X>
- Overrides:
hashCode
in classObject
-
-