Package com.globalmentor.collections
Class AbstractConverterCollection<S,D>
java.lang.Object
com.globalmentor.collections.CollectionDecorator<D>
com.globalmentor.collections.AbstractConverterCollection<S,D>
- Type Parameters:
S
- The type of element contained in the source collection.D
- The type of element contained in the destination collection.
- All Implemented Interfaces:
Iterable<D>
,Collection<D>
A collection that provides access to another collection, automatically converting elements to objects possibly of a different type. The conversion is done on
the fly as elements are requested, and not before.
- Author:
- Garret Wilson
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected class
A custom proxied iterator that converts returned elements on the fly. -
Field Summary
Fields inherited from class com.globalmentor.collections.CollectionDecorator
collection
-
Constructor Summary
ConstructorDescriptionAbstractConverterCollection
(Collection<S> collection) Collection constructor. -
Method Summary
Methods inherited from class com.globalmentor.collections.CollectionDecorator
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, parallelStream, remove, removeAll, removeIf, retainAll, size, spliterator, stream, toArray, toArray
-
Constructor Details
-
AbstractConverterCollection
Collection constructor.- Parameters:
collection
- The collection the elements of which this collection should convert.
-
-
Method Details
-
convert
Converts an object in the collection to another object.- Parameters:
source
- The object to convert.- Returns:
- The converted object.
-
iterator
- Specified by:
iterator
in interfaceCollection<S>
- Specified by:
iterator
in interfaceIterable<S>
- Overrides:
iterator
in classCollectionDecorator<D>
- Returns:
- A custom proxied iterator that will convert returned elements on the fly.
-