|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.atlassian.jira.util.collect.CollectionUtil
public final class CollectionUtil
| Constructor Summary | |
|---|---|
CollectionUtil()
|
|
| Method Summary | ||
|---|---|---|
static
|
contains(Iterable<? extends T> iterable,
Predicate<T> predicate)
Does the supplied Iterable contain anything that matches the predicate? |
|
static
|
contains(Iterator<? extends T> iterator,
Predicate<T> predicate)
Does the supplied Iterator contain anything that matches the predicate? |
|
static
|
copyAsImmutableList(Collection<? extends T> copy)
Return an immutable list copy of the passed collection. |
|
static
|
copyAsImmutableMap(Map<? extends K,? extends V> copy)
Return an immutable copy of the passed map. |
|
static
|
copyAsImmutableSet(Collection<? extends T> copy)
Return an immutable set copy of the passed collection. |
|
static
|
filter(Collection<T> collection,
Predicate<? super T> predicate)
Create a filtered Collection. |
|
static
|
filter(Iterable<T> iterable,
Predicate<? super T> predicate)
Create a filtered Iterable. |
|
static
|
filter(Iterator<T> iterator,
Predicate<? super T> predicate)
Create a filtered Iterator. |
|
static
|
filterByType(Iterable<T> iterable,
Class<R> subclass)
Filter a Collection for the specified subtype. |
|
static
|
findFirstMatch(Iterable<? extends T> iterable,
Predicate<T> predicate)
Return the first found element that the predicate matches. |
|
static
|
first(Iterable<? extends T> iterable)
Get the first element of a an Iterable in iteration order, or null if empty. |
|
static
|
foreach(Iterable<T> iterable,
Consumer<T> consumer)
For each element in the iterator, consume the contents. |
|
static
|
foreach(Iterator<? extends T> iterator,
Consumer<T> consumer)
For each element in the iterator, consume the contents. |
|
static
|
indexOf(Iterable<? extends T> iterable,
Predicate<? super T> predicate)
Returns the index of the first element that matches the predicate. |
|
static
|
map(Map<K,R> map,
Function<R,S> mapper)
Take a map and eagerly transform all values into a new, immutable Map. |
|
static
|
sort(Collection<? extends T> collection,
Comparator<T> comparator)
Copy and sort the passed collection and return an unmodifiable List of the elements. |
|
static
|
toList(Enumeration<? extends T> enumeration)
Turn the enumeration into a list. |
|
static
|
toList(Iterable<? extends T> iterable)
Turn the iterable into a list. |
|
static
|
toList(Iterator<? extends T> iterator)
Turn the iterator into a list. |
|
static
|
toSet(Iterable<? extends T> iterable)
Turn the iterable into a Set. |
|
static
|
toSet(Iterator<? extends T> iterator)
Turn the iterable into a Set. |
|
static
|
transform(Iterable<? extends T> iterable,
Function<T,R> transformer)
Return a List that is transformed from elements of the input type
to elements of the output type by a transformer function. |
|
static
|
transform(Iterator<? extends T> iterator,
Function<T,R> transformer)
Return a List that is transformed from elements of the input type to elements of the output type by a transformer function. |
|
static
|
transformAndFilter(Iterable<T> iterable,
Function<T,R> transformer,
Predicate<R> predicate)
|
|
static
|
transformIterator(Iterator<? extends T> iterator,
Function<T,R> transformer)
Return an Iterator that is transformed from elements of the input
type to elements of the output type by a transformer function. |
|
static
|
transformSet(Iterable<T> iterable,
Function<T,R> transformer)
Return a Set that is transformed from elements of the input type
to elements of the output type by a transformer function. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public CollectionUtil()
| Method Detail |
|---|
public static <T> void foreach(@NotNull
Iterator<? extends T> iterator,
@NotNull
Consumer<T> consumer)
T - the type of element to consumeiterator - to iterate over the elementsconsumer - to consume the elements
public static <T> void foreach(Iterable<T> iterable,
@NotNull
Consumer<T> consumer)
T - the element typeiterable - to iterate over the elements, may be nullconsumer - to consume the elements
public static <T> List<T> toList(@NotNull
Iterator<? extends T> iterator)
T - the element typeiterator - to iterate over the elements
List of the elements in the iterator
public static <T> List<T> toList(@NotNull
Iterable<? extends T> iterable)
T - the element typeiterable - to iterate over the elements
List of the elements in the iterator
public static <T> List<T> toList(@NotNull
Enumeration<? extends T> enumeration)
T - the element typeenumeration - to enumerate over the elements
List of the elements in the iterator
public static <T> Set<T> toSet(@NotNull
Iterable<? extends T> iterable)
T - the element typeiterable - to iterate over the elements
Set of the elements in the iterator
public static <T> Set<T> toSet(@NotNull
Iterator<? extends T> iterator)
T - the element typeiterator - to iterate over the elements
Set of the elements in the iterator
public static <T,R> List<R> transform(@NotNull
Iterator<? extends T> iterator,
@NotNull
Function<T,R> transformer)
T - the input typeR - the out typeiterator - to iterate over the contentstransformer - the function that performs the transformation
public static <T,R> List<R> transform(@NotNull
Iterable<? extends T> iterable,
@NotNull
Function<T,R> transformer)
List that is transformed from elements of the input type
to elements of the output type by a transformer function.
Note, this performs a copy and applies the transform to all elements. If you want a lazily applied function, see Transform
T - the input typeR - the out typeiterable - the contentstransformer - the function that performs the transformation
public static <T,R> Iterator<R> transformIterator(@NotNull
Iterator<? extends T> iterator,
@NotNull
Function<T,R> transformer)
Iterator that is transformed from elements of the input
type to elements of the output type by a transformer function.
T - the input typeR - the out typeiterator - the contentstransformer - the function that performs the transformation
Iterator of the transformed type
public static <T,R> Set<R> transformSet(@NotNull
Iterable<T> iterable,
@NotNull
Function<T,R> transformer)
Set that is transformed from elements of the input type
to elements of the output type by a transformer function.
Note, this performs a copy and applies the transform to all elements.
T - the input typeR - the output typeiterable - the contentstransformer - the function that performs the transformation
public static <T> boolean contains(@NotNull
Iterator<? extends T> iterator,
@NotNull
Predicate<T> predicate)
Iterator contain anything that matches the predicate?
T - the element typeiterator - containing elementspredicate - the matcher
public static <T> boolean contains(@NotNull
Iterable<? extends T> iterable,
@NotNull
Predicate<T> predicate)
Iterable contain anything that matches the predicate?
T - the element typeiterable - containing elementspredicate - the matcher
public static <T> Iterator<T> filter(@NotNull
Iterator<T> iterator,
@NotNull
Predicate<? super T> predicate)
Iterator.
T - the element typeiterator - an iterator that only returns elements approved by the predicatepredicate - for checking the elements
Iterator
public static <T> Iterable<T> filter(@NotNull
Iterable<T> iterable,
@NotNull
Predicate<? super T> predicate)
Iterable.
T - the element typeiterable - an iterable whose iterators only returns elements approved by the predicatepredicate - for checking the elements
Iterable
public static <T,R> Iterable<R> transformAndFilter(Iterable<T> iterable,
Function<T,R> transformer,
Predicate<R> predicate)
public static <T> Collection<T> filter(@NotNull
Collection<T> collection,
@NotNull
Predicate<? super T> predicate)
Collection.
T - the element typecollection - an iterable whose iterators only returns elements approved by the predicatepredicate - for checking the elements
Iterable
public static <T,R extends T> Collection<R> filterByType(@NotNull
Iterable<T> iterable,
@NotNull
Class<R> subclass)
Collection for the specified subtype.
T - the incoming typeR - the result typeiterable - an iterable whose values are of the source typesubclass - the result type, only return elements if they are of this type
Collection of the subtype
public static <T> List<T> sort(@NotNull
Collection<? extends T> collection,
@NotNull
Comparator<T> comparator)
List of the elements.
T - the element typecollection - the collection to copycomparator - for sorting
List view of the elements.
public static <T> List<T> copyAsImmutableList(@NotNull
Collection<? extends T> copy)
T - the type of elements for the returned collection.copy - the collection to copy.
public static <T> Set<T> copyAsImmutableSet(@NotNull
Collection<? extends T> copy)
T - the type of elements for the returned collection.copy - the collection to copy.
public static <K,V> Map<K,V> copyAsImmutableMap(@NotNull
Map<? extends K,? extends V> copy)
K - the type of key in the returned map.V - the type of value in the returned map.copy - the map to copy.
public static <T> T findFirstMatch(@NotNull
Iterable<? extends T> iterable,
Predicate<T> predicate)
T - the type of element to returniterable - that may contain the element to returnpredicate - to match the desired element
public static <T> int indexOf(@NotNull
Iterable<? extends T> iterable,
@NotNull
Predicate<? super T> predicate)
T - the type of the elementsiterable - collection of elementspredicate - to match the desired element
public static <T> T first(@NotNull
Iterable<? extends T> iterable)
Iterable in iteration order, or null if empty.
T - the typeiterable - the thing to get something from.
public static <K,R,S> Map<K,S> map(Map<K,R> map,
Function<R,S> mapper)
K - the key typeR - the original value typeS - the new value typemap - the original mapmapper - the mapping function
for a lazy version.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||