Service Activator Toolkit
Version 1.1.0

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)
           
 List reject(Collection collection, CollectionUtility.Accessor accessor)
           
 List select(Collection collection, CollectionUtility.Accessor accessor)
           
 List toList(Enumeration enumeration)
           
 List toList(Enumeration enumeration, int sizeHint)
           
 
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)

reject

public List reject(Collection collection,
                   CollectionUtility.Accessor accessor)

select

public List select(Collection collection,
                   CollectionUtility.Accessor accessor)

toList

public List toList(Enumeration enumeration)

toList

public List toList(Enumeration enumeration,
                   int sizeHint)

Service Activator Toolkit
Version 1.1.0