|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectch.elca.el4j.util.codingsupport.CollectionUtils
public class CollectionUtils
This class supports methods to handle with collections. It covers only gaps
of class org.springframework.util.CollectionUtils.
| Constructor Summary | |
|---|---|
protected |
CollectionUtils()
Hidden constructor. |
| Method Summary | ||
|---|---|---|
static
|
asList(List<T> list)
Method to always return a list object. |
|
static
|
asMap(Map<K,V> map)
Method to always return a map object. |
|
static
|
asSet(Set<T> set)
Method to always return a set object. |
|
static boolean |
containsOnlyObjectsOfType(Collection<?> c,
Class<?> containingClassType)
Method to check if a collection contains only objects which are equals, a subclass or implements the given class. |
|
static boolean |
containsOnlyObjectsOfType(Collection<?> c,
Class<?>[] containingClassTypes)
Method to check if a collection contains only objects which are equals, a subclass or implements one of the given classes. |
|
static
|
filtered(List<? extends T> list,
Filter<? super T> filter)
returns a filtered view on list. |
|
static
|
find(List<T> list,
T t,
int startAt)
Finds the first element with index at least startAt that equals o. |
|
static boolean |
isEmpty(Collection<?> c)
Null save check if a collection is empty. |
|
static
|
mapped(List<T> list,
Function<? super T,O> function)
Convenience method returning a TransformedList view to the
supplied list. |
|
static Collection |
nullSaveAddAll(Collection base,
Collection annex)
|
|
static
|
orderLike(ExtendedReorderableList<T> list,
List<? extends T> example)
See ExtendedReorderableList.orderLike(List). |
|
static
|
swap(List<T> list,
int i,
int j)
swaps the elements at locations i and j. |
|
static
|
toArray(List<? extends T> list,
Class<T> c)
Copies the list's contents to an array. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
protected CollectionUtils()
| Method Detail |
|---|
public static boolean isEmpty(Collection<?> c)
c - Is the given collection
public static <T> List<T> asList(List<T> list)
list - Is the list which should not be null.
public static <T> Set<T> asSet(Set<T> set)
set - Is the set which should not be null.
public static <K,V> Map<K,V> asMap(Map<K,V> map)
map - Is the map which should not be null.
public static boolean containsOnlyObjectsOfType(Collection<?> c,
Class<?>[] containingClassTypes)
true will be returned.
c - Is the collection to check.containingClassTypes - Are the class types which are expected.
true if the given collection contains only
objects which are equals, a subclass or implements one of the
given classes
public static boolean containsOnlyObjectsOfType(Collection<?> c,
Class<?> containingClassType)
true will be returned.
c - Is the collection to check.containingClassType - Is the class type which is expected.
true if the given collection contains only
objects which are equals, a subclass or implements the given
class.
public static <T> int find(List<T> list,
T t,
int startAt)
throws NoSuchElementException
startAt that equals o. This method may take linear time.
T - the list's element type (duh!)list - the list to searcht - the element to look forstartAt - the index to start the search at
NoSuchElementException - if no such element exists.
public static <T> void orderLike(ExtendedReorderableList<T> list,
List<? extends T> example)
ExtendedReorderableList.orderLike(List).
T - see therelist - see thereexample - see there
public static <T> void swap(List<T> list,
int i,
int j)
i and j.
If this list is a ExtendedReorderableList, its swap method
is invoked, otherwise, set/get is used.
This behaves like Lists always declared a convenience swap method,
that is overridden if ReordableRandomAccessList is implemented.
T - .list - see abovei - see abovej - see above
public static <T> T[] toArray(List<? extends T> list,
Class<T> c)
T - the arrays element typelist - the list to copyc - the element type for the new array
public static <T> FilteredList<T> filtered(List<? extends T> list,
Filter<? super T> filter)
list.
T - .list - see abovefilter - the filter deciding which elements to include
public static <T,O> TransformedList<T,O> mapped(List<T> list,
Function<? super T,O> function)
TransformedList view to the
supplied list.
T - the backing list's element typeO - this list's element typelist - Is the list to transform.function - the transformation function to apply to each element
public static Collection nullSaveAddAll(Collection base,
Collection annex)
base - Is the collection to enrich.annex - Is the collection with the items to enrich the base
collection.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||