Class MemoryStaticIntIDFactory

java.lang.Object
com.helger.base.id.factory.MemoryStaticIntIDFactory
All Implemented Interfaces:
IBaseIDFactory, IIntIDFactory

@ThreadSafe public final class MemoryStaticIntIDFactory extends Object implements IIntIDFactory
An implementation of IIntIDFactory using a single static AtomicInteger.
Author:
Philip Helger
  • Field Details

    • INITIAL_ID

      public static final int INITIAL_ID
      The default start ID to use.
      See Also:
  • Constructor Details

    • MemoryStaticIntIDFactory

      public MemoryStaticIntIDFactory()
      Create a new instance using the shared static counter.
  • Method Details

    • getNewID

      @Nonnegative public int getNewID()
      Create a new unique integer ID.
      Specified by:
      getNewID in interface IIntIDFactory
      Returns:
      The newly created ID.
    • getNewStaticID

      @Nonnegative public static int getNewStaticID()
      Get a new unique int ID from the static counter.
      Returns:
      A new unique int ID. Always ≥ 0.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object