E
- the type of elements in this collectionpublic abstract class ProxiedCollection<E> extends Object implements Collection<E>
Collection
implementation pointing to a given collection
object.
Therefore it allows implementing collections based on invisible collection
types, such as
Collections.unmodifiableCollection(Collection)
or
Collections.synchronizedCollection(Collection)
.
Constructor and Description |
---|
ProxiedCollection(Collection<E> collection)
Creates a new
ProxiedCollection instance. |
Modifier and Type | Method and Description |
---|---|
boolean |
add(E element) |
boolean |
addAll(Collection<? extends E> collection) |
void |
clear() |
boolean |
contains(Object object) |
boolean |
containsAll(Collection<?> collection) |
boolean |
equals(Object object) |
protected Collection<E> |
getWrappedForRead()
Returns the wrapped collection without verifying if modifying it is
prohibited.
|
protected Collection<E> |
getWrappedIfModifiable()
Verifies if this object is modifiable and either returns the wrapped
collection or throws an appropriate exception.
|
int |
hashCode() |
boolean |
isEmpty() |
abstract boolean |
isModifiable()
Flag specifying if this instance can be modified
|
Iterator<E> |
iterator() |
boolean |
remove(Object object) |
boolean |
removeAll(Collection<?> collection) |
boolean |
retainAll(Collection<?> collection) |
int |
size() |
Object[] |
toArray() |
<T> T[] |
toArray(T[] array) |
String |
toString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
parallelStream, removeIf, spliterator, stream
public ProxiedCollection(Collection<E> collection)
ProxiedCollection
instance.collection
- Wrapped collectionpublic boolean add(@Nullable E element)
add
in interface Collection<E>
public boolean addAll(@Nullable Collection<? extends E> collection)
addAll
in interface Collection<E>
public void clear()
clear
in interface Collection<E>
public boolean contains(@Nullable Object object)
contains
in interface Collection<E>
public boolean containsAll(@Nullable Collection<?> collection)
containsAll
in interface Collection<E>
public boolean equals(@CheckForNull Object object)
equals
in interface Collection<E>
equals
in class Object
protected Collection<E> getWrappedIfModifiable()
UnsupportedOperationException
- if this object is unmodifiableprotected Collection<E> getWrappedForRead()
public int hashCode()
hashCode
in interface Collection<E>
hashCode
in class Object
public boolean isEmpty()
isEmpty
in interface Collection<E>
public abstract boolean isModifiable()
true
if this instance is modifiable, else false
public boolean remove(@Nullable Object object)
remove
in interface Collection<E>
public boolean removeAll(@Nullable Collection<?> collection)
removeAll
in interface Collection<E>
public boolean retainAll(@Nullable Collection<?> collection)
retainAll
in interface Collection<E>
public int size()
size
in interface Collection<E>
public Object[] toArray()
toArray
in interface Collection<E>
public <T> T[] toArray(@Nullable T[] array)
toArray
in interface Collection<E>
Copyright © 2025. All rights reserved.