org.keridwen.modelling.group.editor.utils
Class DefaultUniqueIdGenerator

java.lang.Object
  extended by org.keridwen.modelling.group.editor.utils.DefaultUniqueIdGenerator

public class DefaultUniqueIdGenerator
extends Object

Single/ unique id generator. Ids can be not contiguous. This class is a singleton and can be instantiated only one time.

Author:
J.Forest, Artenum.

Field Summary
 HashMap<String,Integer> loadedCharacteristicIds
           
 
Method Summary
 int getCurrentCharacteristicId()
          Return the current maximum Id of Characteristics
 int getCurrentPropertyId()
          Return the current maximum Id of Properties
static DefaultUniqueIdGenerator getInstanceOf()
          Return the singleton of the DefaultUniqueIdGenerator.
 int incrementAndGetCharacteristicId()
          Get a new id, incremented on one and add it in the list.
 int incrementAndGetCharacteristicId(int increment)
          Get a new id, incremented on one and add it in the list.
 int incrementAndGetPropertyId()
          Get a new id, incremented on one and add it in the list.
 int incrementAndGetPropertyId(int increment)
          Get a new id, incremented on one and add it in the list.
 boolean tryToAddCharacteristicId(int id)
           
 boolean tryToAddPropertyId(int id)
          If the id list does not contains the given Id, the present method tries to add it into the id list or return false otherwise.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

loadedCharacteristicIds

public HashMap<String,Integer> loadedCharacteristicIds
Method Detail

getInstanceOf

public static DefaultUniqueIdGenerator getInstanceOf()
Return the singleton of the DefaultUniqueIdGenerator. Should be use in place of the constructor of the present class.

Returns:
- The singleton of the unique id generator.

getCurrentPropertyId

public int getCurrentPropertyId()
Return the current maximum Id of Properties

Returns:

getCurrentCharacteristicId

public int getCurrentCharacteristicId()
Return the current maximum Id of Characteristics

Returns:

incrementAndGetPropertyId

public int incrementAndGetPropertyId()
Get a new id, incremented on one and add it in the list.

Returns:
- a new and incremented of one single id.

incrementAndGetCharacteristicId

public int incrementAndGetCharacteristicId()
Get a new id, incremented on one and add it in the list.

Returns:
- a new and incremented of one single id.

incrementAndGetPropertyId

public int incrementAndGetPropertyId(int increment)
Get a new id, incremented on one and add it in the list.

Parameters:
increment - - increment for the new id w.r.p the current Id.
Returns:
- a new and incremented of the given increment single id.

incrementAndGetCharacteristicId

public int incrementAndGetCharacteristicId(int increment)
Get a new id, incremented on one and add it in the list.

Parameters:
increment - - increment for the new id w.r.p the current Id.
Returns:
- a new and incremented of the given increment single id.

tryToAddPropertyId

public boolean tryToAddPropertyId(int id)
If the id list does not contains the given Id, the present method tries to add it into the id list or return false otherwise. If the given id is higher than the current id this last one is set equal to the given id.

Parameters:
id - - Given input id.
Returns:
true if the id has been successfully added to the id list, false otherwise.

tryToAddCharacteristicId

public boolean tryToAddCharacteristicId(int id)


Copyright © 2012-2013 Artenum. All Rights Reserved.