|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jaggregate.Collections
public class Collections
Methods that should be on Collection
, but aren't for reasons of type safety
or generics restrictions.
Method Summary | ||
---|---|---|
static
|
toArray(Collection<E> collection,
Class<T> componentType)
Answers an array with the same elements as the given collection, with the same size as the collection, and a component type of the given class. |
|
static
|
toDictionary(Collection<E> elements,
UnaryFunctor<? super E,? extends V> mapper)
Answers a dictionary whose keys are the elements of the given collection and whose values are the results of applying the given mapper to the associated element from the collection. |
|
static
|
toIdentityDictionary(Collection<E> elements,
UnaryFunctor<? super E,? extends V> mapper)
Answers a dictionary whose keys are the elements of the given collection and whose values are the results of applying the given mapper to the associated element from the collection. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static <T,E extends T> T[] toArray(Collection<E> collection, Class<T> componentType)
collection
maintains an ordering for its elements, the order of
those elements will be preserved in the result.
T
- the component type of the array to be createdE
- the type of the elements in the collection to convertcollection
- the collection to make an array fromcomponentType
- the desired type of the result array's components
collection
's elements
NullPointerException
- if either collection
or componentType
is null
IllegalArgumentException
- if componentType
is Void.TYPE
Collection.toArray()
,
Creating
an array from a generic Java collectionpublic static <E,V> Dictionary<E,V> toDictionary(Collection<E> elements, UnaryFunctor<? super E,? extends V> mapper)
elements
are traversed in the order specified by Collection.forEachDo(UnaryFunctor)
.
This method would be on Collection
if it weren't
for
these
bugs.
E
- the type of elements in the given collectionV
- the types of the values in the resultant dictionaryelements
- a collectionmapper
- a function to apply to each element of elements
elements
to mapped values
NullPointerException
- if either elements
or mapper
is
null
public static <E,V> IdentityDictionary<E,V> toIdentityDictionary(Collection<E> elements, UnaryFunctor<? super E,? extends V> mapper)
elements
are traversed in the order specified by Collection.forEachDo(UnaryFunctor)
.
This method would be on Collection
if it weren't
for
these
bugs.
E
- the type of elements in the given collectionV
- the types of the values in the resultant dictionaryelements
- a collectionmapper
- a function to apply to each element of elements
elements
to mapped values
NullPointerException
- if either elements
or mapper
is
null
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |