Class MongoUniqueCodeDao
java.lang.Object
dev.getelements.elements.dao.mongo.ucode.MongoUniqueCodeDao
- All Implemented Interfaces:
UniqueCodeDao
-
Nested Class Summary
Nested classes/interfaces inherited from interface dev.getelements.elements.sdk.dao.UniqueCodeDao
UniqueCodeDao.GenerationParameters -
Field Summary
Fields inherited from interface dev.getelements.elements.sdk.dao.UniqueCodeDao
DEFAULT_CODE_LENGTH, DEFAULT_LINGER_MS, DEFAULT_MAX_GENERATION_ATTEMPTS, DEFAULT_TIMEOUT_MS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionFinds the UniqueCode object for the specified code.findMongoCode(String code) generateCode(UniqueCodeDao.GenerationParameters parameters) Generates a unique code with the default length.generateMongoCode(UniqueCodeDao.GenerationParameters parameters) dev.morphia.query.Query<MongoUniqueCode> getActiveCodeQuery(String code) dev.morphia.DatastorevoidsetDatastore(dev.morphia.Datastore datastore) voidsetMapperRegistry(MapperRegistry mapperRegistry) voidsetMongoDBUtils(MongoDBUtils mongoDBUtils) voidsetProfileDao(MongoProfileDao profileDao) voidsetUniqueCodeGenerator(UniqueCodeGenerator uniqueCodeGenerator) voidsetUserDao(MongoUserDao userDao) booleantryReleaseCode(String code) Attempts to release the specified code within the given timeout period.booleantryResetTimeout(String code) Tries to reset the timeout for the specified code, extending its uniqueness period.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface dev.getelements.elements.sdk.dao.UniqueCodeDao
generateCode, getCode, releaseCode, resetTimeout
-
Constructor Details
-
MongoUniqueCodeDao
public MongoUniqueCodeDao()
-
-
Method Details
-
generateCode
Description copied from interface:UniqueCodeDaoGenerates a unique code with the default length.- Specified by:
generateCodein interfaceUniqueCodeDao- Parameters:
parameters- the generation parameters- Returns:
- the generated unique code
-
generateMongoCode
-
findCode
Description copied from interface:UniqueCodeDaoFinds the UniqueCode object for the specified code.- Specified by:
findCodein interfaceUniqueCodeDao- Parameters:
code- the code or an empty Optional if not found- Returns:
- the UniqueCode object wrapped in an Optional
-
findMongoCode
-
tryResetTimeout
Description copied from interface:UniqueCodeDaoTries to reset the timeout for the specified code, extending its uniqueness period. If the code has been released, then this will have no effect.- Specified by:
tryResetTimeoutin interfaceUniqueCodeDao- Parameters:
code- the code- Returns:
- true if the timeout was successfully reset, false otherwise
-
tryReleaseCode
Description copied from interface:UniqueCodeDaoAttempts to release the specified code within the given timeout period. Once released, the code can be reused after a short linger period.- Specified by:
tryReleaseCodein interfaceUniqueCodeDao- Parameters:
code- the code- Returns:
- true if the code was successfully released, false otherwise
-
getActiveCodeQuery
-
getDatastore
public dev.morphia.Datastore getDatastore() -
setDatastore
@Inject public void setDatastore(dev.morphia.Datastore datastore) -
getMongoDBUtils
-
setMongoDBUtils
-
getMapperRegistry
-
setMapperRegistry
-
getUserDao
-
setUserDao
-
getProfileDao
-
setProfileDao
-
getUniqueCodeGenerator
-
setUniqueCodeGenerator
-