Class IdentifierManager


  • public class IdentifierManager
    extends java.lang.Object

    24.08.2009

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static long MAX_ID  
      static long MIN_ID  
    • Constructor Summary

      Constructors 
      Constructor Description
      IdentifierManager​(long lowerbound, long upperbound)  
    • Constructor Detail

      • IdentifierManager

        public IdentifierManager​(long lowerbound,
                                 long upperbound)
        Parameters:
        lowerbound - the lower limit of the id-range to manage. Must be greater than or equal to MIN_ID.
        upperbound - the upper limit of the id-range to manage. Must be less then or equal MAX_ID.
    • Method Detail

      • reserve

        public long reserve​(long id)
      • reserveNew

        public long reserveNew()
        Returns:
        a new identifier.
        Throws:
        java.lang.IllegalStateException - if no more identifiers are available, then an Exception is raised.
      • release

        public boolean release​(long id)
        Parameters:
        id - the identifier to release. Must be greater than or equal to lowerbound and must be less than or equal to upperbound
        Returns:
        true, if the identifier was reserved and has been successfully released, false, if the identifier was not reserved.
      • getRemainingIdentifiers

        public long getRemainingIdentifiers()