Class ShortTopiaIdFactory

java.lang.Object
org.nuiton.topia.persistence.internal.ShortTopiaIdFactory
All Implemented Interfaces:
Serializable, TopiaIdFactory

public class ShortTopiaIdFactory extends Object implements TopiaIdFactory

Does the same than FullyQualifiedNamePlusUuidTopiaIdFactory but produces shorter topiaId. The class-name part uses only simple class names, and the random part is base64 encoded.

Note: This TopiaIdFactory requires that you do not have several entities with the same simple class name.
Author:
Arnaud Thimel (Code Lutin)
See Also:
  • Field Details

  • Constructor Details

    • ShortTopiaIdFactory

      public ShortTopiaIdFactory()
  • Method Details

    • newTopiaId

      public <E extends TopiaEntity> String newTopiaId(Class<E> entityClass, TopiaEntity topiaEntity)
      Description copied from interface: TopiaIdFactory
      Generates a new topiaId for the given entity type and the given entity.
      Specified by:
      newTopiaId in interface TopiaIdFactory
      Type Parameters:
      E - type of entity
      Parameters:
      entityClass - type of entity (must be a not null interface)
      topiaEntity - the entity on which we want to generate the id (must be not null)
      Returns:
      the new topiaId for the given entity
    • newTopiaId

      public <E extends TopiaEntity> String newTopiaId(Class<E> entityClass, String randomPart)
      Description copied from interface: TopiaIdFactory
      Builds a new topiaId for the given entity type and the given random part.
      Specified by:
      newTopiaId in interface TopiaIdFactory
      Type Parameters:
      E - type of entity
      Parameters:
      entityClass - type of entity (must be a not null interface)
      randomPart - the random part of the topiaId
      Returns:
      the new topiaId
    • getClassName

      public <E extends TopiaEntity> Class<E> getClassName(String topiaId)
      Specified by:
      getClassName in interface TopiaIdFactory
      Type Parameters:
      E - type of the entity
      Parameters:
      topiaId - the topiaId to inspect
      Returns:
      the FQN part of the topiaId
    • findClassName

      protected <E extends TopiaEntity> Class<E> findClassName(String simpleClassName) throws ClassNotFoundException
      Throws:
      ClassNotFoundException
    • getSeparator

      public String getSeparator()
      Specified by:
      getSeparator in interface TopiaIdFactory
      Returns:
      the separator between the FQN and the random part of any topiaId.
    • getRandomPart

      public String getRandomPart(String topiaId)
      Specified by:
      getRandomPart in interface TopiaIdFactory
      Parameters:
      topiaId - the topiaId to inspect
      Returns:
      the random part of the topiaId
    • isTopiaId

      public boolean isTopiaId(String str)
      Specified by:
      isTopiaId in interface TopiaIdFactory
      Parameters:
      str - FIXME
      Returns:
      true if given argument is a well formatted topiaId