Class IntSequenceIDSource

  • All Implemented Interfaces:
    IDSource<Integer>

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

      • IntSequenceIDSource

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

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

      • nextID

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