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>
An unmodifiable view over a
Collection
. Unlike the view returned via
Collections.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:
-
Method Summary
Modifier and TypeMethodDescriptionboolean
boolean
addAll
(Collection<? extends E> c) void
clear()
boolean
boolean
containsAll
(Collection<?> c) static <T> @NonNull Collection<T>
create
(@NonNull Collection<T> collection) Create an unmodifiable view of the target collection.boolean
isEmpty()
iterator()
boolean
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 Details
-
create
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
-
iterator
-
size
public int size()- Specified by:
size
in interfaceCollection<E>
-
isEmpty
public boolean isEmpty()- Specified by:
isEmpty
in interfaceCollection<E>
-
contains
- Specified by:
contains
in interfaceCollection<E>
-
toArray
- Specified by:
toArray
in interfaceCollection<E>
-
toArray
public <T> T[] toArray(T[] a) - Specified by:
toArray
in interfaceCollection<E>
-
containsAll
- Specified by:
containsAll
in interfaceCollection<E>
-
add
- Specified by:
add
in interfaceCollection<E>
-
addAll
- Specified by:
addAll
in interfaceCollection<E>
-
remove
- Specified by:
remove
in interfaceCollection<E>
-
removeAll
- Specified by:
removeAll
in interfaceCollection<E>
-
retainAll
- Specified by:
retainAll
in interfaceCollection<E>
-
clear
public void clear()- Specified by:
clear
in interfaceCollection<E>
-
toString
-