Service Activator Toolkit
Version 1.1.0 (20081206)

org.eclipse.soda.sat.core.util
Class CollectionUtility

java.lang.Object
  extended by org.eclipse.soda.sat.core.util.CollectionUtility

public class CollectionUtility
extends Object


Nested Class Summary
static interface CollectionUtility.Accessor
           
static interface CollectionUtility.InjectionAccessor
           
 
Method Summary
 List collect(Collection collection, CollectionUtility.Accessor accessor)
          For each of the objects in the specified Collection collect objects using the specified Accessor object.
 Object detect(Collection collection, CollectionUtility.Accessor accessor)
          Detect the first object in the specified Collection for which the specified Accessor does not return null.
 int estimateHashedCollectionSize(int capacity)
          Estimate the size of a hashed collection based on the specified capacity.
static CollectionUtility getInstance()
          Public getter for the CollectionUtility singleton instance.
 Object inject(Collection collection, Object value, CollectionUtility.InjectionAccessor accessor)
          Inject each item in the specified collection into the specified Object using the specified accessor.
 List reject(Collection collection, CollectionUtility.Accessor accessor)
          Reject those items in the specified Collection as defined by the specified Accessor.
 List select(Collection collection, CollectionUtility.Accessor accessor)
          Select those items in the specified Collection as defined by the specified Accessor.
 List toList(Enumeration enumeration)
          Convert the specified Enumeration into a List.
 List toList(Enumeration enumeration, List list)
          Add the specified Enumeration to the specified List.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static CollectionUtility getInstance()
Public getter for the CollectionUtility singleton instance.

Returns:
CollectionUtility

collect

public List collect(Collection collection,
                    CollectionUtility.Accessor accessor)
For each of the objects in the specified Collection collect objects using the specified Accessor object.

Parameters:
collection - A Collection.
accessor - The object Acccessor.
Returns:
A list of objects.

detect

public Object detect(Collection collection,
                     CollectionUtility.Accessor accessor)
Detect the first object in the specified Collection for which the specified Accessor does not return null.

Parameters:
collection - A Collection.
accessor - An Accessor.
Returns:
The detected object.

estimateHashedCollectionSize

public int estimateHashedCollectionSize(int capacity)
Estimate the size of a hashed collection based on the specified capacity. Unlike other collections, hashed collections need to be created bigger than the number of elements they intend to hold. This method estimates how big a hashed collections must be to efficiently hold the specified number of elements without needing to grow.

Parameters:
capacity - The number of elements the hash collections must hold.
Returns:
The estimate size of the hashed collection.

inject

public Object inject(Collection collection,
                     Object value,
                     CollectionUtility.InjectionAccessor accessor)
Inject each item in the specified collection into the specified Object using the specified accessor.

Parameters:
collection - A Collection of objects to be injected.
value - The target for the injection.
accessor - The accessor defining the injection behavior.
Returns:
The injection result.

reject

public List reject(Collection collection,
                   CollectionUtility.Accessor accessor)
Reject those items in the specified Collection as defined by the specified Accessor.

Parameters:
collection - The items from which to reject.
accessor - The rejection accessor.
Returns:
A List of items that were not rejected, never null.

select

public List select(Collection collection,
                   CollectionUtility.Accessor accessor)
Select those items in the specified Collection as defined by the specified Accessor.

Parameters:
collection - The items from which to select.
accessor - The selection accessor.
Returns:
A List of selected items, never null

toList

public List toList(Enumeration enumeration)
Convert the specified Enumeration into a List.

Parameters:
enumeration - The source Enumeration.
Returns:
The target List containing the items in the source Enumeration

toList

public List toList(Enumeration enumeration,
                   List list)
Add the specified Enumeration to the specified List.

Parameters:
enumeration - The source Enumeration.
list - The target List.
Returns:
The target List.

Service Activator Toolkit
Version 1.1.0 (20081206)