Class UniqueIdGenerator


  • public final class UniqueIdGenerator
    extends java.lang.Object
    Generator of unique identifiers.
    Since:
    15820
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.concurrent.atomic.AtomicLong idCounter  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void advanceUniqueId​(long newId)
      Advances the current primitive unique id to skip a range of values.
      long currentUniqueId()
      Returns the current primitive unique id.
      long generateUniqueId()
      Generates a new primitive unique id.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • idCounter

        private final java.util.concurrent.atomic.AtomicLong idCounter
    • Method Detail

      • generateUniqueId

        public long generateUniqueId()
        Generates a new primitive unique id.
        Returns:
        new primitive unique (negative) id
        Since:
        16108 (made public)
      • currentUniqueId

        public long currentUniqueId()
        Returns the current primitive unique id.
        Returns:
        the current primitive unique (negative) id (last generated)
      • advanceUniqueId

        public void advanceUniqueId​(long newId)
        Advances the current primitive unique id to skip a range of values.
        Parameters:
        newId - new unique id
        Throws:
        java.lang.IllegalArgumentException - if newId is greater than current unique id