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

public Class TransformedSortedBag<E>

extends TransformedBag<E>
implements SortedBag<E>
Class Inheritance
All Implemented Interfaces
org.apache.commons.collections4.SortedBag, org.apache.commons.collections4.Bag, java.util.Collection, java.lang.Iterable
Type Parameters
<E>
the type of elements in this bag
Imports
java.util.Comparator, org.apache.commons.collections4.SortedBag, .Transformer

Decorates another SortedBag 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
TransformedSortedBag(final SortedBag<E>
the bag to decorate, must not be null
bag
,
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 org.apache.commons.collections4.SortedBag.comparator.

Returns the comparator associated with this sorted set, or null if it uses its elements' natural ordering.
public E
first()

Implements org.apache.commons.collections4.SortedBag.first.

Returns the first (lowest) member.
protected SortedBag<E>

Returns:

the decorated bag
getSortedBag
()

Gets the decorated bag.

public E
last()

Implements org.apache.commons.collections4.SortedBag.last.

Returns the last (highest) member.
public static <
the type of the elements in the bag
E
>
TransformedSortedBag<E>

Returns:

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

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

public static <
the type of the elements in the bag
E
>
TransformedSortedBag<E>

Returns:

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

Factory method to create a transforming sorted bag.

Inherited from org.apache.commons.collections4.bag.TransformedBag:
addequalsgetBaggetCounthashCoderemovetransformedBagtransformingBaguniqueSet

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Hides org.apache.commons.collections4.bag.TransformedBag.serialVersionUID.

Serialization version

Constructor Detail

TransformedSortedBagback to summary
protected TransformedSortedBag(final SortedBag<E> bag, final Transformer<? super E, ? extends E> transformer)

Constructor that wraps (not copies).

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

Parameters
bag:SortedBag<E>

the bag 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 bag or transformer is null

Method Detail

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

Implements org.apache.commons.collections4.SortedBag.comparator.

Doc from org.apache.commons.collections4.SortedBag.comparator.

Returns the comparator associated with this sorted set, or null if it uses its elements' natural ordering.

Returns:Comparator<? super E>

the comparator in use, or null if natural ordering

Annotations
@Override
firstback to summary
public E first()

Implements org.apache.commons.collections4.SortedBag.first.

Doc from org.apache.commons.collections4.SortedBag.first.

Returns the first (lowest) member.

Returns:E

the first element in the sorted bag

Annotations
@Override
getSortedBagback to summary
protected SortedBag<E> getSortedBag()

Gets the decorated bag.

Returns:SortedBag<E>

the decorated bag

lastback to summary
public E last()

Implements org.apache.commons.collections4.SortedBag.last.

Doc from org.apache.commons.collections4.SortedBag.last.

Returns the last (highest) member.

Returns:E

the last element in the sorted bag

Annotations
@Override
transformedSortedBagback to summary
public static <E> TransformedSortedBag<E> transformedSortedBag(final SortedBag<E> bag, final Transformer<? super E, ? extends E> transformer)

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

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

Parameters
<E>
the type of the elements in the bag
bag:SortedBag<E>

the bag to decorate, must not be null

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

the transformer to use for conversion, must not be null

Returns:TransformedSortedBag<E>

a new transformed SortedBag

Exceptions
NullPointerException:
if bag or transformer is null
Since
4.0
transformingSortedBagback to summary
public static <E> TransformedSortedBag<E> transformingSortedBag(final SortedBag<E> bag, final Transformer<? super E, ? extends E> transformer)

Factory method to create a transforming sorted bag.

If there are any elements already in the bag being decorated, they are NOT transformed. Contrast this with transformedSortedBag(SortedBag, Transformer).

Parameters
<E>
the type of the elements in the bag
bag:SortedBag<E>

the bag to decorate, must not be null

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

the transformer to use for conversion, must not be null

Returns:TransformedSortedBag<E>

a new transformed SortedBag

Exceptions
NullPointerException:
if bag or transformer is null
Since
4.0