Utils
Class SetUtils

java.lang.Object
  extended by Utils.SetUtils

public class SetUtils
extends java.lang.Object

Utility class fo sets

Version:
1.0

Nested Class Summary
static class SetUtils.SetHasMultipleElementsException
          Exception thrown if an attempt is made to get the single element from a set that has multiple elements.
 
Method Summary
static
<T> T
getSingleElement(java.util.Set<T> set)
          Gets the single element of a set if it has only one element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getSingleElement

public static <T> T getSingleElement(java.util.Set<T> set)
                          throws SetUtils.SetHasMultipleElementsException
Gets the single element of a set if it has only one element. Throws an exception if there is more than one element. Returns null if there are no elements

Type Parameters:
T - The type of the elements of the set
Parameters:
set - The set
Returns:
The single element in the set
Throws:
SetUtils.SetHasMultipleElementsException - If the set has multiple elements in it