Package com.helger.io.id.factory
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final CharsetThe charset to use for writing the filestatic final intThe default number of values to reserve with a single IO actionFields inherited from class com.helger.base.id.factory.AbstractPersistingIntIDFactory
m_aLock -
Constructor Summary
ConstructorsConstructorDescriptionFileIntIDFactory(@NonNull File aFile) Constructor using theDEFAULT_RESERVE_COUNT.FileIntIDFactory(@NonNull File aFile, int nReserveCount) Constructor with explicit reserve count. -
Method Summary
Methods inherited from class com.helger.base.id.factory.AbstractPersistingIntIDFactory
getNewID, getReserveCount, internalGetReserveCountUnlocked, setReserveCount
-
Field Details
-
CHARSET_TO_USE
The charset to use for writing the file -
DEFAULT_RESERVE_COUNT
public static final int DEFAULT_RESERVE_COUNTThe default number of values to reserve with a single IO action- See Also:
-
-
Constructor Details
-
FileIntIDFactory
Constructor using theDEFAULT_RESERVE_COUNT.- Parameters:
aFile- The file to persist the ID counter to. May not benull. Must be readable and writable.
-
FileIntIDFactory
Constructor with explicit reserve count.- Parameters:
aFile- The file to persist the ID counter to. May not benull. Must be readable and writable.nReserveCount- The number of IDs to reserve with a single IO action. Must be > 0.
-
-
Method Details
-
getFile
- Returns:
- The
Fileto write to, as provided in the constructor. Nevernull.
-
readAndUpdateIDCounter
@MustBeLocked(WRITE) protected final int readAndUpdateIDCounter(@Nonnegative int nReserveCount) - Specified by:
readAndUpdateIDCounterin classcom.helger.base.id.factory.AbstractPersistingIntIDFactory
-
equals
- Overrides:
equalsin classcom.helger.base.id.factory.AbstractPersistingIntIDFactory
-
hashCode
public int hashCode()- Overrides:
hashCodein classcom.helger.base.id.factory.AbstractPersistingIntIDFactory
-
toString
- Overrides:
toStringin classcom.helger.base.id.factory.AbstractPersistingIntIDFactory
-