public class CollectionUtil extends CollectionUtil
| Constructor and Description |
|---|
CollectionUtil() |
| Modifier and Type | Method and Description |
|---|---|
static <K,V> Set<Map.Entry<K,V>> |
asEntrySetExtender(Map<K,V> m)
see
MapEntrySet. |
static <T> ListSet<T> |
asListSet(Collection<T> listOrSet)
|
static <T> T |
find(Collection<T> source,
Class<T> type,
String attributeName,
Object value)
finds an entry through bean-reflection
|
static Collection<?> |
getContainer(Object obj)
if
#isContainer(Object) returns true, obj is an array, collection or map. this method returns a
collection where obj is wrapped into. |
static <T extends Comparable<T>> |
getFilteredBetween(Collection<T> src,
T from,
T to)
delegates to
getFilteringBetween(Iterable, Comparable, Comparable), copying the filtered list. |
static <T> Collection<T> |
getFilteredBetween(Collection<T> src,
T from,
T to,
boolean ignoreCase)
delegates to
getFilteringBetween(Iterable, Object, Object, boolean), copying the filtered list. |
static <T> Collection<T> |
getFilteredCollection(Iterable<T> src,
IPredicate<T> predicate) |
static <I extends Iterable<T>,T> |
getFiltering(I src,
IPredicate<T> filter)
getFiltering
|
static <I extends Iterable<T>,T> |
getFiltering(I src,
StringBuilder expression)
filters the given collection.
|
static <I extends Iterable<T>,T extends Comparable<T>> |
getFilteringBetween(I src,
T from,
T to)
filters the given collection.
|
static <I extends Iterable<T>,T> |
getFilteringBetween(I src,
T from,
T to,
boolean ignoreCase)
filters the given collection through its string representations.
|
static <I extends Map<S,T>,S,T extends Comparable<T>> |
getFilteringMapKey(I src,
IPredicate<T> filter)
getFiltering
|
static <S,T> Collection<T> |
getTransformedCollection(Collection<S> toTransform,
String attributeName)
delegates to
getTransformedCollection(Collection, String, Class). |
static <S,T> Collection<T> |
getTransformedCollection(Collection<S> toTransform,
String attributeName,
Class<T> transformedType)
transform a collection.
|
static <I extends Iterable<T>,S,T> |
getTransforming(Iterable<S> src,
ITransformer<S,T> transformer)
getTransforming
|
static <I extends Iterable<T>,S,T> |
getTransforming(Iterable<S> src,
ITransformer<S,T> transformer,
IPredicate<T> filter)
combines transforming and filtering a collection
|
static <S,T> Collection<T> |
next(Iterator<S> elements,
int count,
ITransformer<S,T> transformer)
iterates through next count elements and returns a new sublist containing them. useful for performance
optimizations sending statements to a server. if you don't need a transformer you may use List.sublist(..)
|
static <T> T |
remove(Collection<T> source,
Class<T> type,
String attributeName,
Object value)
remove
|
static <S> Collection<String> |
toStringTransformed(Collection<S> toTransform) |
static <T> Collection<?> |
wrap(Collection<T> source,
Class<T> type,
String attributeName)
wrap source collection holding instances of type 'type' into a new collection - holding values given by
attributeName.
|
addAll, asArray, asList, asListCombined, asStandardArrayList, concat, concat, concatNew, contains, copy, copyOfRange, copyOfRange, findEnum, fuzzyFind, get, getEnumNames, getEnumValues, getList, getSortedList, getSortedList, getSortedList, hasNoValues, indexOf, load, removeEmptyEntries, split, swap, writepublic static final <T> ListSet<T> asListSet(Collection<T> listOrSet)
public static <S,T> Collection<T> getTransformedCollection(Collection<S> toTransform, String attributeName)
getTransformedCollection(Collection, String, Class).public static <S,T> Collection<T> getTransformedCollection(Collection<S> toTransform, String attributeName, Class<T> transformedType)
S - real type of collection itemsT - transformed type of collection itemstoTransform - original collectionattributeName - attribute name to use to get the transformed typepublic static <S> Collection<String> toStringTransformed(Collection<S> toTransform)
public static <T> Collection<T> getFilteredCollection(Iterable<T> src, IPredicate<T> predicate)
src - full collectionpredicate - filterpublic static final <T> T remove(Collection<T> source, Class<T> type, String attributeName, Object value)
T - collection typesource - source collectionattributeName - attribute name of typevalue - value to search to be removedpublic static final <T> T find(Collection<T> source, Class<T> type, String attributeName, Object value)
T - collection typesource - source collectionattributeName - attribute name of typevalue - value to search to be foundpublic static final <T> Collection<?> wrap(Collection<T> source, Class<T> type, String attributeName)
T - source collection item typesource - source collectiontype - source collection typeattributeName - attribute of source collection item to get the value as wrapper stored in the new collectionpublic static final <S,T> Collection<T> next(Iterator<S> elements, int count, ITransformer<S,T> transformer)
CollectionmyEntities = null; Iterator<MySearchViewBean> searchIt = akten.iterator(); ITransformer<MySearchViewBean, Long> toNumbers = new ITransformer<MySearchViewBean, Long>() { @Override public Long transform(MySearchViewBean arg0) { return arg0.getSpecificNumber(); } }; for (Collection<Long> specNumbers = CollectionUtil.next(searchIt, blockSize, toNumbers); searchIt.hasNext(); specNumbers = CollectionUtil.next(searchIt, blockSize, toNumbers)) { myEntities = myService.getMyEntityBeans(specNumbers); ... }
T - element typeelements - iterator on each next call this iterator should be the identical instance!count - block size for. will be the size of the returned sub listtransformer - (optional) to transform the items of elements to the type T to be filled into the new list.public static final <T extends Comparable<T>> Collection<T> getFilteredBetween(Collection<T> src, T from, T to)
getFilteringBetween(Iterable, Comparable, Comparable), copying the filtered list.public static final <T> Collection<T> getFilteredBetween(Collection<T> src, T from, T to, boolean ignoreCase)
getFilteringBetween(Iterable, Object, Object, boolean), copying the filtered list.public static final <I extends Iterable<T>,T> I getFiltering(I src, IPredicate<T> filter)
src - collection to filterfilter - filterpublic static final <I extends Map<S,T>,S,T extends Comparable<T>> I getFilteringMapKey(I src, IPredicate<T> filter)
src - map to filterfilter - key filterpublic static final <I extends Iterable<T>,T> I getFiltering(I src, StringBuilder expression)
T - collection item typesrc - collection to filterexpression - regular expression to be used as filter. the toString() methods of objects will be used to
match against.public static final <I extends Iterable<T>,T extends Comparable<T>> I getFilteringBetween(I src, T from, T to)
CollectionUtil.getList(Iterator) to create a copy.T - collection item typesrc - collection to filterfrom - minimum objectto - maximum objectpublic static final <I extends Iterable<T>,T> I getFilteringBetween(I src, T from, T to, boolean ignoreCase)
CollectionUtil.getList(Iterator) to create a copy.T - collection item typesrc - collection to filterfrom - minimum objectto - maximum objectpublic static final <I extends Iterable<T>,S,T> I getTransforming(Iterable<S> src, ITransformer<S,T> transformer)
I - iterable typeT - iterable content typesrc - mostly a collectiontransformer - transformerTransformingIterator as iterator.public static final <I extends Iterable<T>,S,T> I getTransforming(Iterable<S> src, ITransformer<S,T> transformer, IPredicate<T> filter)
I - iterable typeT - iterable content typesrc - mostly a collectiontransformer - transformerfilter - filterpublic static <K,V> Set<Map.Entry<K,V>> asEntrySetExtender(Map<K,V> m)
MapEntrySet.public static final Collection<?> getContainer(Object obj)
#isContainer(Object) returns true, obj is an array, collection or map. this method returns a
collection where obj is wrapped into.obj - Copyright © 2012–2018. All rights reserved.