Class MongoUniqueCodeDao

java.lang.Object
dev.getelements.elements.dao.mongo.ucode.MongoUniqueCodeDao
All Implemented Interfaces:
UniqueCodeDao

public class MongoUniqueCodeDao extends Object implements UniqueCodeDao
  • Constructor Details

    • MongoUniqueCodeDao

      public MongoUniqueCodeDao()
  • Method Details

    • generateCode

      public UniqueCode generateCode(UniqueCodeDao.GenerationParameters parameters)
      Description copied from interface: UniqueCodeDao
      Generates a unique code with the default length.
      Specified by:
      generateCode in interface UniqueCodeDao
      Parameters:
      parameters - the generation parameters
      Returns:
      the generated unique code
    • generateMongoCode

      public MongoUniqueCode generateMongoCode(UniqueCodeDao.GenerationParameters parameters)
    • findCode

      public Optional<UniqueCode> findCode(String code)
      Description copied from interface: UniqueCodeDao
      Finds the UniqueCode object for the specified code.
      Specified by:
      findCode in interface UniqueCodeDao
      Parameters:
      code - the code or an empty Optional if not found
      Returns:
      the UniqueCode object wrapped in an Optional
    • findMongoCode

      public Optional<MongoUniqueCode> findMongoCode(String code)
    • tryResetTimeout

      public boolean tryResetTimeout(String code)
      Description copied from interface: UniqueCodeDao
      Tries 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:
      tryResetTimeout in interface UniqueCodeDao
      Parameters:
      code - the code
      Returns:
      true if the timeout was successfully reset, false otherwise
    • tryReleaseCode

      public boolean tryReleaseCode(String code)
      Description copied from interface: UniqueCodeDao
      Attempts to release the specified code within the given timeout period. Once released, the code can be reused after a short linger period.
      Specified by:
      tryReleaseCode in interface UniqueCodeDao
      Parameters:
      code - the code
      Returns:
      true if the code was successfully released, false otherwise
    • getActiveCodeQuery

      public dev.morphia.query.Query<MongoUniqueCode> getActiveCodeQuery(String code)
    • getDatastore

      public dev.morphia.Datastore getDatastore()
    • setDatastore

      @Inject public void setDatastore(dev.morphia.Datastore datastore)
    • getMongoDBUtils

      public MongoDBUtils getMongoDBUtils()
    • setMongoDBUtils

      @Inject public void setMongoDBUtils(MongoDBUtils mongoDBUtils)
    • getMapperRegistry

      public MapperRegistry getMapperRegistry()
    • setMapperRegistry

      @Inject public void setMapperRegistry(MapperRegistry mapperRegistry)
    • getUserDao

      public MongoUserDao getUserDao()
    • setUserDao

      @Inject public void setUserDao(MongoUserDao userDao)
    • getProfileDao

      public MongoProfileDao getProfileDao()
    • setProfileDao

      @Inject public void setProfileDao(MongoProfileDao profileDao)
    • getUniqueCodeGenerator

      public UniqueCodeGenerator getUniqueCodeGenerator()
    • setUniqueCodeGenerator

      @Inject public void setUniqueCodeGenerator(UniqueCodeGenerator uniqueCodeGenerator)