uk.co.agena.minerva.util.model
Class Identifier

java.lang.Object
  extended by uk.co.agena.minerva.util.model.Identifier

public class Identifier
extends java.lang.Object

The Identifier is a central helper class that can determine the next available ID with respect to a list of Identifiable objects.


Constructor Summary
Identifier()
           
 
Method Summary
static Identifiable getIdentifiableWithId(java.util.List identifiables, int id)
           
static int getNextAvailableId(java.util.List listOfIdentifiables)
          Takes a List of Identifiable objects, examines each object and determines the next free ID.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Identifier

public Identifier()
Method Detail

getNextAvailableId

public static int getNextAvailableId(java.util.List listOfIdentifiables)
Takes a List of Identifiable objects, examines each object and determines the next free ID. This method is typically called after an Identifiable object has been created but just before it is added to a List. The object is created with an invalid ID, the List to which it will be added is then passed to this method in order to find the next available ID, the ID of the object is set accordingly and the object is finally added to the List.

This method ensures that IDs are reused. For example, take a List of objects with the following IDs: 1, 2, 3, 4. If the object with ID 2 is deleted and the List is then passed to getNextAvailableId, the ID 2 would be returned, since it is no longer being used by any object in the List.


getIdentifiableWithId

public static Identifiable getIdentifiableWithId(java.util.List identifiables,
                                                 int id)


Copyright © 2006 Agena Ltd. All Rights Reserved.