Class LongSequenceIDSource

  • All Implemented Interfaces:
    IDSource<Long>

    public final class LongSequenceIDSource
    extends Object
    implements IDSource<Long>
    Thread-safe source for unique IDs. This particular implementation restricts values to those positive integer values that can be represented by the long data type. Provides sequenced 64-bit IDs.
    • Constructor Detail

      • LongSequenceIDSource

        public LongSequenceIDSource​(long firstValue)
        Parameters:
        firstValue - The value at which to start the sequence (must be non-negative).
      • LongSequenceIDSource

        public LongSequenceIDSource()
        Creates a sequence that starts at zero.
    • Method Detail

      • nextID

        public Long nextID()
        Implementing classes are responsible for synchronization if concurrent invocations of this method are required.
        Specified by:
        nextID in interface IDSource<Long>
        Returns:
        The next ID.