Class MemoryIntIDFactory

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

@ThreadSafe public final class MemoryIntIDFactory extends Object implements IIntIDFactory
A default implementation for non-negative in-memory IDs.
Author:
Philip Helger
  • Field Details

    • DEFAULT_START_ID

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

    • MemoryIntIDFactory

      public MemoryIntIDFactory()
      Default constructor starting at DEFAULT_START_ID.
    • MemoryIntIDFactory

      public MemoryIntIDFactory(@Nonnegative int nStartID)
      Constructor with a custom start ID.
      Parameters:
      nStartID - The start ID to use. Must be ≥ 0.
  • Method Details

    • getNewID

      public int getNewID()
      Create a new unique integer ID.
      Specified by:
      getNewID in interface IIntIDFactory
      Returns:
      The newly created ID.
    • 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