Class FileIntIDFactory

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

@ThreadSafe public class FileIntIDFactory extends com.helger.base.id.factory.AbstractPersistingIntIDFactory
File based persisting IIntIDFactory implementation.
Author:
Philip Helger
  • Field Details

    • CHARSET_TO_USE

      public static final Charset CHARSET_TO_USE
      The charset to use for writing the file
    • DEFAULT_RESERVE_COUNT

      public static final int DEFAULT_RESERVE_COUNT
      The default number of values to reserve with a single IO action
      See Also:
  • Constructor Details

    • FileIntIDFactory

      public FileIntIDFactory(@NonNull File aFile)
      Constructor using the DEFAULT_RESERVE_COUNT.
      Parameters:
      aFile - The file to persist the ID counter to. May not be null. Must be readable and writable.
    • FileIntIDFactory

      public FileIntIDFactory(@NonNull File aFile, @Nonnegative int nReserveCount)
      Constructor with explicit reserve count.
      Parameters:
      aFile - The file to persist the ID counter to. May not be null. Must be readable and writable.
      nReserveCount - The number of IDs to reserve with a single IO action. Must be > 0.
  • Method Details

    • getFile

      public final @NonNull File getFile()
      Returns:
      The File to write to, as provided in the constructor. Never null.
    • readAndUpdateIDCounter

      @MustBeLocked(WRITE) protected final int readAndUpdateIDCounter(@Nonnegative int nReserveCount)
      Specified by:
      readAndUpdateIDCounter in class com.helger.base.id.factory.AbstractPersistingIntIDFactory
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class com.helger.base.id.factory.AbstractPersistingIntIDFactory
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class com.helger.base.id.factory.AbstractPersistingIntIDFactory
    • toString

      public String toString()
      Overrides:
      toString in class com.helger.base.id.factory.AbstractPersistingIntIDFactory