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

public Class TransformedSortedSet<E>

extends TransformedSet<E>
implements SortedSet<E>
Class Inheritance
All Implemented Interfaces
java.util.SortedSet, java.util.SequencedSet, java.util.Set, java.util.Collection, java.lang.Iterable, java.util.SequencedCollection
Known Direct Subclasses
org.apache.commons.collections4.set.TransformedNavigableSet
Type Parameters
<E>
the type of the elements in this set
Imports
java.util.Comparator, .SortedSet, org.apache.commons.collections4.Transformer

Decorates another SortedSet to transform objects that are added.

The add methods are affected by this class. Thus objects must be removed or searched for using their transformed form. For example, if the transformation converts Strings to Integers, you must use the Integer form to remove objects.

This class is Serializable from Commons Collections 3.1.

Since
3.0

Field Summary

Modifier and TypeField and Description
private static final long

Constructor Summary

AccessConstructor and Description
protected
TransformedSortedSet(final SortedSet<E>
the set to decorate, must not be null
set
,
final Transformer<? super E, ? extends E>
the transformer to use for conversion, must not be null
transformer
)

Constructor that wraps (not copies).

Method Summary

Modifier and TypeMethod and Description
public Comparator<? super E>
comparator()

Implements java.util.SortedSet.comparator.

Returns the comparator used to order the elements in this set, or null if this set uses the natural ordering of its elements.
public E
first()

Implements java.util.SortedSet.first.

Returns the first (lowest) element currently in this set.
protected SortedSet<E>

Returns:

the decorated set
getSortedSet
()

Gets the decorated set.

public SortedSet<E>
headSet(final E
high endpoint (exclusive) of the returned set
toElement
)

Implements java.util.SortedSet.headSet.

Returns a view of the portion of this set whose elements are strictly less than toElement.
public E
last()

Implements java.util.SortedSet.last.

Returns the last (highest) element currently in this set.
public SortedSet<E>
subSet(final E
low endpoint (inclusive) of the returned set
fromElement
,
final E
high endpoint (exclusive) of the returned set
toElement
)

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
)

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
>
TransformedSortedSet<E>

Returns:

a new transformed SortedSet
transformedSortedSet
(final SortedSet<E>
the set to decorate, must not be null
set
,
final Transformer<? super E, ? extends E>
the transformer to use for conversion, must not be null
transformer
)

Factory method to create a transforming sorted set that will transform existing contents of the specified sorted set.

public static <
the element type
E
>
TransformedSortedSet<E>

Returns:

a new transformed SortedSet
transformingSortedSet
(final SortedSet<E>
the set to decorate, must not be null
set
,
final Transformer<? super E, ? extends E>
the transformer to use for conversion, must not be null
transformer
)

Factory method to create a transforming sorted set.

Inherited from org.apache.commons.collections4.set.TransformedSet:
equalshashCodetransformedSettransformingSet

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

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

Serialization version

Constructor Detail

TransformedSortedSetback to summary
protected TransformedSortedSet(final SortedSet<E> set, final Transformer<? super E, ? extends E> transformer)

Constructor that wraps (not copies).

If there are any elements already in the set being decorated, they are NOT transformed.

Parameters
set:SortedSet<E>

the set to decorate, must not be null

transformer:Transformer<? super E, ? extends E>

the transformer to use for conversion, must not be null

Exceptions
NullPointerException:
if set or transformer is null

Method Detail

comparatorback to summary
public Comparator<? super E> comparator()

Implements java.util.SortedSet.comparator.

Doc from java.util.SortedSet.comparator.

Returns the comparator used to order the elements in this set, or null if this set uses the natural ordering of its elements.

Returns:Comparator<? super E>

the comparator used to order the elements in this set, or null if this set uses the natural ordering of its elements

Annotations
@Override
firstback to summary
public E first()

Implements java.util.SortedSet.first.

Doc from java.util.SortedSet.first.

Returns the first (lowest) element currently in this set.

Returns:E

the first (lowest) element currently in this set

Annotations
@Override
getSortedSetback to summary
protected SortedSet<E> getSortedSet()

Gets the decorated set.

Returns:SortedSet<E>

the decorated set

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

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
lastback to summary
public E last()

Implements java.util.SortedSet.last.

Doc from java.util.SortedSet.last.

Returns the last (highest) element currently in this set.

Returns:E

the last (highest) element currently in this set

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

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)

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
transformedSortedSetback to summary
public static <E> TransformedSortedSet<E> transformedSortedSet(final SortedSet<E> set, final Transformer<? super E, ? extends E> transformer)

Factory method to create a transforming sorted set that will transform existing contents of the specified sorted set.

If there are any elements already in the set being decorated, they will be transformed by this method. Contrast this with transformingSortedSet(SortedSet, Transformer).

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

the set to decorate, must not be null

transformer:Transformer<? super E, ? extends E>

the transformer to use for conversion, must not be null

Returns:TransformedSortedSet<E>

a new transformed SortedSet

Exceptions
NullPointerException:
if set or transformer is null
Since
4.0
transformingSortedSetback to summary
public static <E> TransformedSortedSet<E> transformingSortedSet(final SortedSet<E> set, final Transformer<? super E, ? extends E> transformer)

Factory method to create a transforming sorted set.

If there are any elements already in the set being decorated, they are NOT transformed. Contrast this with transformedSortedSet(SortedSet, Transformer).

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

the set to decorate, must not be null

transformer:Transformer<? super E, ? extends E>

the transformer to use for conversion, must not be null

Returns:TransformedSortedSet<E>

a new transformed SortedSet

Exceptions
NullPointerException:
if set or transformer is null
Since
4.0