Package com.helger.io.id.factory
Class FileLongIDFactory
java.lang.Object
com.helger.base.id.factory.AbstractPersistingLongIDFactory
com.helger.io.id.factory.FileLongIDFactory
- All Implemented Interfaces:
com.helger.base.id.factory.IBaseIDFactory,com.helger.base.id.factory.ILongIDFactory
@ThreadSafe
public class FileLongIDFactory
extends com.helger.base.id.factory.AbstractPersistingLongIDFactory
File based persisting ILongIDFactory 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.AbstractPersistingLongIDFactory
m_aLock -
Constructor Summary
ConstructorsConstructorDescriptionFileLongIDFactory(@NonNull File aFile) Constructor using theDEFAULT_RESERVE_COUNT.FileLongIDFactory(@NonNull File aFile, int nReserveCount) Constructor with explicit reserve count. -
Method Summary
Methods inherited from class com.helger.base.id.factory.AbstractPersistingLongIDFactory
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
-
FileLongIDFactory
Constructor using theDEFAULT_RESERVE_COUNT.- Parameters:
aFile- The file to persist the ID counter to. May not benull. Must be readable and writable.
-
FileLongIDFactory
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 long readAndUpdateIDCounter(@Nonnegative int nReserveCount) - Specified by:
readAndUpdateIDCounterin classcom.helger.base.id.factory.AbstractPersistingLongIDFactory
-
equals
- Overrides:
equalsin classcom.helger.base.id.factory.AbstractPersistingLongIDFactory
-
hashCode
public int hashCode()- Overrides:
hashCodein classcom.helger.base.id.factory.AbstractPersistingLongIDFactory
-
toString
- Overrides:
toStringin classcom.helger.base.id.factory.AbstractPersistingLongIDFactory
-