Top Description Fields Constructors Methods
org.apache.commons.collections4.set

public final Class UnmodifiableSortedSet<E>

extends AbstractSortedSetDecorator<E>
implements Unmodifiable
Class Inheritance
All Implemented Interfaces
org.apache.commons.collections4.Unmodifiable
Type Parameters
<E>
the type of the elements in this set
Imports
java.io.IOException, .ObjectInputStream, .ObjectOutputStream, java.util.Collection, .Iterator, .SortedSet, java.util.function.Predicate, org.apache.commons.collections4.Unmodifiable, org.apache.commons.collections4.iterators.UnmodifiableIterator

Decorates another SortedSet to ensure it can't be altered.

This class is Serializable from Commons Collections 3.1.

Attempts to modify it will result in an UnsupportedOperationException.

Since
3.0

Field Summary

Modifier and TypeField and Description
private static final long

Constructor Summary

AccessConstructor and Description
private
UnmodifiableSortedSet(final SortedSet<E>
the set to decorate, must not be null
set
)

Constructor that wraps (not copies).

Method Summary

Modifier and TypeMethod and Description
public boolean
add(final E
element to be added to this set
object
)

Overrides org.apache.commons.collections4.collection.AbstractCollectionDecorator.add.

Implements java.util.Set.add, java.util.Collection.add.

Adds the specified element to this set if it is not already present (optional operation).
public boolean
addAll(final Collection<? extends E>
collection containing elements to be added to this set
coll
)

Overrides org.apache.commons.collections4.collection.AbstractCollectionDecorator.addAll.

Implements java.util.Set.addAll, java.util.Collection.addAll.

Adds all of the elements in the specified collection to this set if they're not already present (optional operation).
public void
clear()

Overrides org.apache.commons.collections4.collection.AbstractCollectionDecorator.clear.

Implements java.util.Set.clear, java.util.Collection.clear.

Removes all of the elements from this set (optional operation).
public SortedSet<E>
headSet(final E
high endpoint (exclusive) of the returned set
toElement
)

Overrides org.apache.commons.collections4.set.AbstractSortedSetDecorator.headSet.

Implements java.util.SortedSet.headSet.

Returns a view of the portion of this set whose elements are strictly less than toElement.
public Iterator<E>
private void
readObject(final ObjectInputStream
the input stream
in
)

Read the collection in using a custom routine.

public boolean
remove(final Object
object to be removed from this set, if present
object
)

Overrides org.apache.commons.collections4.collection.AbstractCollectionDecorator.remove.

Implements java.util.Set.remove, java.util.Collection.remove.

Removes the specified element from this set if it is present (optional operation).
public boolean
removeAll(final Collection<?>
collection containing elements to be removed from this set
coll
)

Overrides org.apache.commons.collections4.collection.AbstractCollectionDecorator.removeAll.

Implements java.util.Set.removeAll, java.util.Collection.removeAll.

Removes from this set all of its elements that are contained in the specified collection (optional operation).
public boolean
removeIf(Predicate<? super E>
a predicate which returns true for elements to be removed
filter
)

Overrides org.apache.commons.collections4.collection.AbstractCollectionDecorator.removeIf.

Overrides default java.util.Collection.removeIf.

Removes all of the elements of this collection that satisfy the given predicate.
public boolean
retainAll(final Collection<?>
collection containing elements to be retained in this set
coll
)

Overrides org.apache.commons.collections4.collection.AbstractCollectionDecorator.retainAll.

Implements java.util.Set.retainAll, java.util.Collection.retainAll.

Retains only the elements in this set that are contained in the specified collection (optional operation).
public SortedSet<E>
subSet(final E
low endpoint (inclusive) of the returned set
fromElement
,
final E
high endpoint (exclusive) of the returned set
toElement
)

Overrides org.apache.commons.collections4.set.AbstractSortedSetDecorator.subSet.

Implements java.util.SortedSet.subSet.

Returns a view of the portion of this set whose elements range from fromElement, inclusive, to toElement, exclusive.
public SortedSet<E>
tailSet(final E
low endpoint (inclusive) of the returned set
fromElement
)

Overrides org.apache.commons.collections4.set.AbstractSortedSetDecorator.tailSet.

Implements java.util.SortedSet.tailSet.

Returns a view of the portion of this set whose elements are greater than or equal to fromElement.
public static <
the element type
E
>
SortedSet<E>

Returns:

a new unmodifiable SortedSet
unmodifiableSortedSet
(final SortedSet<E>
the set to decorate, must not be null
set
)

Factory method to create an unmodifiable set.

private void
writeObject(final ObjectOutputStream
the output stream
out
)

Write the collection out using a custom routine.

Inherited from org.apache.commons.collections4.set.AbstractSortedSetDecorator:
comparatordecoratedfirstlast

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Hides org.apache.commons.collections4.set.AbstractSortedSetDecorator.serialVersionUID.

Serialization version

Constructor Detail

UnmodifiableSortedSetback to summary
private UnmodifiableSortedSet(final SortedSet<E> set)

Constructor that wraps (not copies).

Parameters
set:SortedSet<E>

the set to decorate, must not be null

Exceptions
NullPointerException:
if set is null

Method Detail

addback to summary
public boolean add(final E object)

Overrides org.apache.commons.collections4.collection.AbstractCollectionDecorator.add.

Implements java.util.Set.add, java.util.Collection.add.

Doc from java.util.Set.add.

Adds the specified element to this set if it is not already present (optional operation). More formally, adds the specified element e to this set if the set contains no element e2 such that Objects.equals(e, e2). If this set already contains the element, the call leaves the set unchanged and returns false. In combination with the restriction on constructors, this ensures that sets never contain duplicate elements.

The stipulation above does not imply that sets must accept all elements; sets may refuse to add any particular element, including null, and throw an exception, as described in the specification for Collection.add. Individual set implementations should clearly document any restrictions on the elements that they may contain.

Parameters
object:E

element to be added to this set

Returns:boolean

true if this set did not already contain the specified element

Annotations
@Override
addAllback to summary
public boolean addAll(final Collection<? extends E> coll)

Overrides org.apache.commons.collections4.collection.AbstractCollectionDecorator.addAll.

Implements java.util.Set.addAll, java.util.Collection.addAll.

Doc from java.util.Set.addAll.

Adds all of the elements in the specified collection to this set if they're not already present (optional operation). If the specified collection is also a set, the addAll operation effectively modifies this set so that its value is the union of the two sets. The behavior of this operation is undefined if the specified collection is modified while the operation is in progress.

Parameters
coll:Collection<? extends E>

collection containing elements to be added to this set

Returns:boolean

true if this set changed as a result of the call

Annotations
@Override
clearback to summary
public void clear()

Overrides org.apache.commons.collections4.collection.AbstractCollectionDecorator.clear.

Implements java.util.Set.clear, java.util.Collection.clear.

Doc from java.util.Set.clear.

Removes all of the elements from this set (optional operation). The set will be empty after this call returns.

Annotations
@Override
headSetback to summary
public SortedSet<E> headSet(final E toElement)

Overrides org.apache.commons.collections4.set.AbstractSortedSetDecorator.headSet.

Implements java.util.SortedSet.headSet.

Doc from java.util.SortedSet.headSet.

Returns a view of the portion of this set whose elements are strictly less than toElement. The returned set is backed by this set, so changes in the returned set are reflected in this set, and vice-versa. The returned set supports all optional set operations that this set supports.

The returned set will throw an IllegalArgumentException on an attempt to insert an element outside its range.

Parameters
toElement:E

high endpoint (exclusive) of the returned set

Returns:SortedSet<E>

a view of the portion of this set whose elements are strictly less than toElement

Annotations
@Override
iteratorback to summary
public Iterator<E> iterator()

Overrides org.apache.commons.collections4.collection.AbstractCollectionDecorator.iterator.

Implements java.util.Set.iterator, java.util.Collection.iterator.

Doc from java.util.Set.iterator.

Returns an iterator over the elements in this set. The elements are returned in no particular order (unless this set is an instance of some class that provides a guarantee).

Returns:Iterator<E>

an iterator over the elements in this set

Annotations
@Override
readObjectback to summary
private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException

Read the collection in using a custom routine.

Parameters
in:ObjectInputStream

the input stream

Annotations
@SuppressWarnings:unchecked
Exceptions
IOException:
if an error occurs while reading from the stream
ClassNotFoundException:
if an object read from the stream can not be loaded
removeback to summary
public boolean remove(final Object object)

Overrides org.apache.commons.collections4.collection.AbstractCollectionDecorator.remove.

Implements java.util.Set.remove, java.util.Collection.remove.

Doc from java.util.Set.remove.

Removes the specified element from this set if it is present (optional operation). More formally, removes an element e such that Objects.equals(o, e), if this set contains such an element. Returns true if this set contained the element (or equivalently, if this set changed as a result of the call). (This set will not contain the element once the call returns.)

Parameters
object:Object

object to be removed from this set, if present

Returns:boolean

true if this set contained the specified element

Annotations
@Override
removeAllback to summary
public boolean removeAll(final Collection<?> coll)

Overrides org.apache.commons.collections4.collection.AbstractCollectionDecorator.removeAll.

Implements java.util.Set.removeAll, java.util.Collection.removeAll.

Doc from java.util.Set.removeAll.

Removes from this set all of its elements that are contained in the specified collection (optional operation). If the specified collection is also a set, this operation effectively modifies this set so that its value is the asymmetric set difference of the two sets.

Parameters
coll:Collection<?>

collection containing elements to be removed from this set

Returns:boolean

true if this set changed as a result of the call

Annotations
@Override
removeIfback to summary
public boolean removeIf(Predicate<? super E> filter)

Overrides org.apache.commons.collections4.collection.AbstractCollectionDecorator.removeIf.

Overrides default java.util.Collection.removeIf.

Doc from java.util.Collection.removeIf.

Removes all of the elements of this collection that satisfy the given predicate. Errors or runtime exceptions thrown during iteration or by the predicate are relayed to the caller.

Parameters
filter:Predicate<? super E>

a predicate which returns true for elements to be removed

Returns:boolean

true if any elements were removed

Annotations
@Override
Since
4.4
retainAllback to summary
public boolean retainAll(final Collection<?> coll)

Overrides org.apache.commons.collections4.collection.AbstractCollectionDecorator.retainAll.

Implements java.util.Set.retainAll, java.util.Collection.retainAll.

Doc from java.util.Set.retainAll.

Retains only the elements in this set that are contained in the specified collection (optional operation). In other words, removes from this set all of its elements that are not contained in the specified collection. If the specified collection is also a set, this operation effectively modifies this set so that its value is the intersection of the two sets.

Parameters
coll:Collection<?>

collection containing elements to be retained in this set

Returns:boolean

true if this set changed as a result of the call

Annotations
@Override
subSetback to summary
public SortedSet<E> subSet(final E fromElement, final E toElement)

Overrides org.apache.commons.collections4.set.AbstractSortedSetDecorator.subSet.

Implements java.util.SortedSet.subSet.

Doc from java.util.SortedSet.subSet.

Returns a view of the portion of this set whose elements range from fromElement, inclusive, to toElement, exclusive. (If fromElement and toElement are equal, the returned set is empty.) The returned set is backed by this set, so changes in the returned set are reflected in this set, and vice-versa. The returned set supports all optional set operations that this set supports.

The returned set will throw an IllegalArgumentException on an attempt to insert an element outside its range.

Parameters
fromElement:E

low endpoint (inclusive) of the returned set

toElement:E

high endpoint (exclusive) of the returned set

Returns:SortedSet<E>

a view of the portion of this set whose elements range from fromElement, inclusive, to toElement, exclusive

Annotations
@Override
tailSetback to summary
public SortedSet<E> tailSet(final E fromElement)

Overrides org.apache.commons.collections4.set.AbstractSortedSetDecorator.tailSet.

Implements java.util.SortedSet.tailSet.

Doc from java.util.SortedSet.tailSet.

Returns a view of the portion of this set whose elements are greater than or equal to fromElement. The returned set is backed by this set, so changes in the returned set are reflected in this set, and vice-versa. The returned set supports all optional set operations that this set supports.

The returned set will throw an IllegalArgumentException on an attempt to insert an element outside its range.

Parameters
fromElement:E

low endpoint (inclusive) of the returned set

Returns:SortedSet<E>

a view of the portion of this set whose elements are greater than or equal to fromElement

Annotations
@Override
unmodifiableSortedSetback to summary
public static <E> SortedSet<E> unmodifiableSortedSet(final SortedSet<E> set)

Factory method to create an unmodifiable set.

Parameters
<E>
the element type
set:SortedSet<E>

the set to decorate, must not be null

Returns:SortedSet<E>

a new unmodifiable SortedSet

Exceptions
NullPointerException:
if set is null
Since
4.0
writeObjectback to summary
private void writeObject(final ObjectOutputStream out) throws IOException

Write the collection out using a custom routine.

Parameters
out:ObjectOutputStream

the output stream

Exceptions
IOException:
if an error occurs while writing to the stream