org.argouml.util
Class CollectionUtil

java.lang.Object
  extended by org.argouml.util.CollectionUtil

public final class CollectionUtil
extends java.lang.Object

Some helper methods for dealing with collections.

Stereotype:
utility

Method Summary
static java.lang.Object getFirstItem(java.util.Collection c)
          Return the first item from a collection using the most efficient method possible.
static java.lang.Object getFirstItemOrNull(java.util.Collection c)
          Return the first item from a collection using the most efficient method possible.
static int indexOf(java.util.Collection c, java.lang.Object elem)
          Get the index position of an element in a collection
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getFirstItem

public static java.lang.Object getFirstItem(java.util.Collection c)
Return the first item from a collection using the most efficient method possible.

Parameters:
c - The Collection.
Returns:
the first element of a Collection.
Throws:
java.util.NoSuchElementException - if the collection is empty.

getFirstItemOrNull

public static java.lang.Object getFirstItemOrNull(java.util.Collection c)
Return the first item from a collection using the most efficient method possible. Returns null for an empty collection.

Parameters:
c - The Collection.
Returns:
the first element of a Collection.

indexOf

public static int indexOf(java.util.Collection c,
                          java.lang.Object elem)
Get the index position of an element in a collection

Parameters:
c - The Collection.
elem - the element to find the index of
Returns:
the element index


ArgoUML © 1996-2006ArgoUML HomepageArgoUML Developers' pageArgoUML Cookbook