eu.lindenbaum.maven.util
Class CollectionUtils

java.lang.Object
  extended by eu.lindenbaum.maven.util.CollectionUtils

public final class CollectionUtils
extends Object

Containing utilities related to collections.

Since:
2.1.0
Author:
Tobias Schlager , Timo Koepke

Nested Class Summary
static interface CollectionUtils.FoldFunction<A,B>
          Function that returns a value of type B for an argument of type A and an accumulator argument of type B.
static interface CollectionUtils.MapFunction<A,B>
          Function that returns a value of type B for an argument of type A.
 
Constructor Summary
CollectionUtils()
           
 
Method Summary
static
<A> Collection<A>
filter(Predicate<A> p, Collection<A> as)
          Returns the Collection of elements satisfying a given predicate.
static
<A,B> B
foldl(CollectionUtils.FoldFunction<A,B> f, B initial, Collection<A> as)
          Applies a function f on each element of a collection passing through an accumulator argument which is an argument for the call to f.
static
<A,B> Collection<B>
map(CollectionUtils.MapFunction<A,B> f, Collection<A> as)
          Maps a collection with elements of type A to a collection of type B, where the resulting elements are generated by applying the function f to each element of the given collection.
static
<B> Collection<B>
map(CollectionUtils.MapFunction<com.ericsson.otp.erlang.OtpErlangObject,B> f, com.ericsson.otp.erlang.OtpErlangList as)
          Maps an OtpErlangList with elements of type OtpErlangObject to a collection of type B, where the resulting elements are generated by applying the function f to each element of the given collection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CollectionUtils

public CollectionUtils()
Method Detail

map

public static <A,B> Collection<B> map(CollectionUtils.MapFunction<A,B> f,
                                      Collection<A> as)
Maps a collection with elements of type A to a collection of type B, where the resulting elements are generated by applying the function f to each element of the given collection. The input collection is not modified.

Parameters:
f - the function for generating elements
as - the original collection
Returns:
the generated collection

map

public static <B> Collection<B> map(CollectionUtils.MapFunction<com.ericsson.otp.erlang.OtpErlangObject,B> f,
                                    com.ericsson.otp.erlang.OtpErlangList as)
Maps an OtpErlangList with elements of type OtpErlangObject to a collection of type B, where the resulting elements are generated by applying the function f to each element of the given collection.

Parameters:
f - the function for generating elements
as - the original list
Returns:
the generated collection

filter

public static <A> Collection<A> filter(Predicate<A> p,
                                       Collection<A> as)
Returns the Collection of elements satisfying a given predicate. The input collection is not modified.

Parameters:
p - the predicate for testing elements
as - the original collection
Returns:
the filtered collection

foldl

public static <A,B> B foldl(CollectionUtils.FoldFunction<A,B> f,
                            B initial,
                            Collection<A> as)
Applies a function f on each element of a collection passing through an accumulator argument which is an argument for the call to f.

Parameters:
f - the function generating results
initial - the start argument for the fold operation
as - the collection to iterate
Returns:
the accumulator as returned by the last call to f


Copyright © 2012 Lindenbaum GmbH. All Rights Reserved.