net.shibboleth.utilities.java.support.collection
Class CollectionSupport

java.lang.Object
  extended by net.shibboleth.utilities.java.support.collection.CollectionSupport

public final class CollectionSupport
extends Object

Helper methods for working with collections of objects.


Constructor Summary
private CollectionSupport()
          Constructor.
 
Method Summary
static
<T> boolean
addIf(Collection<T> target, Collection<T> elements, com.google.common.base.Predicate<? super T> predicate)
          Adds a collection of elements to a collection for each element that meets the requirements of a given predicate.
static
<T> boolean
addIf(Collection<T> target, Collection<T> elements, com.google.common.base.Predicate<? super T> predicate, com.google.common.base.Function<? super T,T> elementPreprocessor)
          Adds a collection of elements to a collection for each element that meets the requirements of a given predicate.
static
<T> boolean
addIf(Collection<T> target, T element, com.google.common.base.Predicate<? super T> predicate)
          Adds an element to a collection if it meets the requirements of a given predicate.
static
<T> boolean
addIf(Collection<T> target, T element, com.google.common.base.Predicate<? super T> predicate, com.google.common.base.Function<? super T,T> elementPreprocessor)
          Adds an element to a collection if it meets the requirements of a given predicate.
static
<T> boolean
removeIf(Collection<T> target, Collection<T> elements, com.google.common.base.Predicate<? super T> predicate)
          Removes a collection of elements to a collection for each element that meets the requirements of a given predicate.
static
<T> boolean
removeIf(Collection<T> target, Collection<T> elements, com.google.common.base.Predicate<? super T> predicate, com.google.common.base.Function<? super T,T> elementPreprocessor)
          Removes a collection of elements to a collection for each element that meets the requirements of a given predicate.
static
<T> boolean
removeIf(Collection<T> target, T element, com.google.common.base.Predicate<? super T> predicate)
          Removes an element to a collection if it meets the requirements of a given predicate.
static
<T> boolean
removeIf(Collection<T> target, T element, com.google.common.base.Predicate<? super T> predicate, com.google.common.base.Function<? super T,T> elementPreprocessor)
          Removes an element to a collection if it meets the requirements of a given predicate.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CollectionSupport

private CollectionSupport()
Constructor.

Method Detail

addIf

public static <T> boolean addIf(@Nonnull
                                Collection<T> target,
                                @Nullable
                                T element,
                                @Nonnull
                                com.google.common.base.Predicate<? super T> predicate)
Adds an element to a collection if it meets the requirements of a given predicate.

Type Parameters:
T - type of element in the collection
Parameters:
target - collection to which elements will be added
element - element that may be added to the collection
predicate - predicate the given element must meet in order to be added to the given collection
Returns:
true if the given element was added to the given collection

addIf

public static <T> boolean addIf(@Nonnull
                                Collection<T> target,
                                @Nullable
                                T element,
                                @Nonnull
                                com.google.common.base.Predicate<? super T> predicate,
                                @Nonnull
                                com.google.common.base.Function<? super T,T> elementPreprocessor)
Adds an element to a collection if it meets the requirements of a given predicate.

Type Parameters:
T - type of element in the collection
Parameters:
target - collection to which elements will be added
element - element that may be added to the collection
predicate - predicate the given element must meet in order to be added to the given collection
elementPreprocessor - function applied to element prior to predicate evaluation and being added the collection
Returns:
true if the given element was added to the given collection

addIf

public static <T> boolean addIf(@Nonnull
                                Collection<T> target,
                                @Nullable
                                Collection<T> elements,
                                @Nonnull
                                com.google.common.base.Predicate<? super T> predicate)
Adds a collection of elements to a collection for each element that meets the requirements of a given predicate.

Type Parameters:
T - type of element in the collection
Parameters:
target - collection to which elements will be added
elements - elements that may be added to the collection
predicate - predicate the given element must meet in order to be added to the given collection
Returns:
true if the given target had elements added to it

addIf

public static <T> boolean addIf(@Nonnull
                                Collection<T> target,
                                @Nullable
                                Collection<T> elements,
                                @Nonnull
                                com.google.common.base.Predicate<? super T> predicate,
                                @Nonnull
                                com.google.common.base.Function<? super T,T> elementPreprocessor)
Adds a collection of elements to a collection for each element that meets the requirements of a given predicate.

Type Parameters:
T - type of element in the collection
Parameters:
target - collection to which elements will be added
elements - elements that may be added to the collection
predicate - predicate the given element must meet in order to be added to the given collection
elementPreprocessor - function applied to element prior to predicate evaluation and being added the collection
Returns:
true if the given target had elements added to it

removeIf

public static <T> boolean removeIf(@Nonnull
                                   Collection<T> target,
                                   @Nullable
                                   T element,
                                   @Nonnull
                                   com.google.common.base.Predicate<? super T> predicate)
Removes an element to a collection if it meets the requirements of a given predicate.

Type Parameters:
T - type of element in the collection
Parameters:
target - collection to which elements will be removed
element - element that may be removed from the collection
predicate - predicate the given element must meet in order to be removed from the given collection
Returns:
true if the given element was removed from the given collection

removeIf

public static <T> boolean removeIf(@Nonnull
                                   Collection<T> target,
                                   @Nullable
                                   T element,
                                   @Nonnull
                                   com.google.common.base.Predicate<? super T> predicate,
                                   @Nonnull
                                   com.google.common.base.Function<? super T,T> elementPreprocessor)
Removes an element to a collection if it meets the requirements of a given predicate.

Type Parameters:
T - type of element in the collection
Parameters:
target - collection to which elements will be removed
element - element that may be removed from the collection
predicate - predicate the given element must meet in order to be removed from the given collection
elementPreprocessor - function applied to element prior to predicate evaluation and being removed from the collection
Returns:
true if the given element was added to the given collection

removeIf

public static <T> boolean removeIf(@Nonnull
                                   Collection<T> target,
                                   @Nullable
                                   Collection<T> elements,
                                   @Nonnull
                                   com.google.common.base.Predicate<? super T> predicate)
Removes a collection of elements to a collection for each element that meets the requirements of a given predicate.

Type Parameters:
T - type of element in the collection
Parameters:
target - collection to which elements will be removed
elements - elements that may be removed from the collection
predicate - predicate the given element must meet in order to be removed from the given collection
Returns:
true if the given target had elements added to it

removeIf

public static <T> boolean removeIf(@Nonnull
                                   Collection<T> target,
                                   @Nullable
                                   Collection<T> elements,
                                   @Nonnull
                                   com.google.common.base.Predicate<? super T> predicate,
                                   @Nonnull
                                   com.google.common.base.Function<? super T,T> elementPreprocessor)
Removes a collection of elements to a collection for each element that meets the requirements of a given predicate.

Type Parameters:
T - type of element in the collection
Parameters:
target - collection to which elements will be removed
elements - elements that may be removed from the collection
predicate - predicate the given element must meet in order to be removed from the given collection
elementPreprocessor - function applied to element prior to predicate evaluation and being removed from the collection
Returns:
true if the given target had elements added to it


Copyright © 1999-2012. All Rights Reserved.