org.decisiondeck.utils.collections
Class CollectionVariousUtils
java.lang.Object
org.decisiondeck.utils.collections.CollectionVariousUtils
public class CollectionVariousUtils
- extends Object
|
Method Summary |
static Collection<String> |
asStrings(Enum<?>[] values)
|
static
|
containsInOrder(Iterable<T> container,
Iterable<T> contained)
Tells whether a container iterable is a superset of some contained iterable and contains the objects in the same
order as they are found in the contained iterable. |
static
|
isContiguous(Iterable<T> subSet,
Iterable<T> superSet)
Tests whether the given subset is indeed a subset of the given superset, and that all its elements are contained
contiguously in the super set. |
static
|
newHashMapNoNull()
|
static
|
newHashSetNoNull()
|
static
|
newLinkedHashSetNoNull()
|
static
|
transformKeys(Map<K,V> map,
Function<K,L> keyFunction)
|
static
|
transformMap(Map<K,V> map,
Function<K,L> keyFunction,
Function<V,W> valueFunction)
|
static
|
union(Iterable<Set<T>> sets)
Builds a read-only live view of the union of all the given sets. |
CollectionVariousUtils
public CollectionVariousUtils()
containsInOrder
public static <T> boolean containsInOrder(Iterable<T> container,
Iterable<T> contained)
- Tells whether a container iterable is a superset of some contained iterable and contains the objects in the same
order as they are found in the contained iterable. If the container contains, in order, the strings "s1", "s2",
"s3", and the contained object contains "s1", "s3", this method returns
true. If the contained
object contains "s3", "s1", this method returns false. If the contained object is not a subset of
the contained object, this method returns false.
- Type Parameters:
T - the type of searched objects.- Parameters:
container - not null.contained - not null.
- Returns:
true iff the given container contains every elements of contained in the same order (and
possibly more).
transformMap
public static <K,V,L,W> Map<L,W> transformMap(Map<K,V> map,
Function<K,L> keyFunction,
Function<V,W> valueFunction)
transformKeys
public static <K,V,L> Map<L,V> transformKeys(Map<K,V> map,
Function<K,L> keyFunction)
union
public static <T> Set<T> union(Iterable<Set<T>> sets)
- Builds a read-only live view of the union of all the given sets. Warning: the view is said to be live because
changing the content of one of the sets contained in the given iterable will be reflected in the view. However,
adding a set to the iterables object after this method returns is not reflected in the object returned by this
method.
- Type Parameters:
T - the type of the objects in the sets.- Parameters:
sets - not null, no null sets inside.
- Returns:
- not
null.
newHashMapNoNull
public static <K,V> Map<K,V> newHashMapNoNull()
newLinkedHashSetNoNull
public static <E> Set<E> newLinkedHashSetNoNull()
newHashSetNoNull
public static <E> Set<E> newHashSetNoNull()
isContiguous
public static <T> boolean isContiguous(Iterable<T> subSet,
Iterable<T> superSet)
- Tests whether the given subset is indeed a subset of the given superset, and that all its elements are contained
contiguously in the super set. This is a stronger property than
containsInOrder(java.lang.Iterable, java.lang.Iterable).
- Type Parameters:
T - the type of elements in the sets.- Parameters:
subSet - not null.superSet - not null.
- Returns:
true iff the subset is contiguous in the super set.
asStrings
public static Collection<String> asStrings(Enum<?>[] values)
Copyright © 2011. All Rights Reserved.