Package org.opendaylight.yangtools.util
Class UnmodifiableCollection<E>
- java.lang.Object
-
- org.opendaylight.yangtools.util.UnmodifiableCollection<E>
-
- Type Parameters:
E
- the type of elements in this collection
- All Implemented Interfaces:
Serializable
,Iterable<E>
,Collection<E>
public final class UnmodifiableCollection<E> extends Object implements Collection<E>, Serializable
An unmodifiable view over aCollection
. Unlike the view returned viaCollections.unmodifiableCollection(Collection)
, this class checks its argument to ensure multiple encapsulation does not occur.This class checks the argument so it prevents multiple encapsulation. Subclasses of
ImmutableCollection
are also recognized and not encapsulated.- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(E e)
boolean
addAll(Collection<? extends E> c)
void
clear()
boolean
contains(Object o)
boolean
containsAll(Collection<?> c)
static <T> @NonNull Collection<T>
create(@NonNull Collection<T> collection)
Create an unmodifiable view of the target collection.boolean
isEmpty()
@NonNull Iterator<E>
iterator()
boolean
remove(Object o)
boolean
removeAll(Collection<?> c)
boolean
retainAll(Collection<?> c)
int
size()
Object[]
toArray()
<T> T[]
toArray(T[] a)
@NonNull String
toString()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
equals, hashCode, parallelStream, removeIf, spliterator, stream, toArray
-
-
-
-
Method Detail
-
create
public static <T> @NonNull Collection<T> create(@NonNull Collection<T> collection)
Create an unmodifiable view of the target collection. If the instance is known to be unmodifiable, that instance is returned.- Parameters:
collection
- Target collection- Returns:
- An unmodifiable view of the collection
- Throws:
NullPointerException
- ifcollection
is null
-
size
public int size()
- Specified by:
size
in interfaceCollection<E>
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty
in interfaceCollection<E>
-
contains
public boolean contains(Object o)
- Specified by:
contains
in interfaceCollection<E>
-
toArray
public Object[] toArray()
- Specified by:
toArray
in interfaceCollection<E>
-
toArray
public <T> T[] toArray(T[] a)
- Specified by:
toArray
in interfaceCollection<E>
-
containsAll
public boolean containsAll(Collection<?> c)
- Specified by:
containsAll
in interfaceCollection<E>
-
add
public boolean add(E e)
- Specified by:
add
in interfaceCollection<E>
-
addAll
public boolean addAll(Collection<? extends E> c)
- Specified by:
addAll
in interfaceCollection<E>
-
remove
public boolean remove(Object o)
- Specified by:
remove
in interfaceCollection<E>
-
removeAll
public boolean removeAll(Collection<?> c)
- Specified by:
removeAll
in interfaceCollection<E>
-
retainAll
public boolean retainAll(Collection<?> c)
- Specified by:
retainAll
in interfaceCollection<E>
-
clear
public void clear()
- Specified by:
clear
in interfaceCollection<E>
-
-