Class JandexEntityIdFactory

java.lang.Object
org.fuin.ddd4j.core.JandexEntityIdFactory
All Implemented Interfaces:
EntityIdFactory

public final class JandexEntityIdFactory extends Object implements EntityIdFactory
Registry that is built up by scanning for classes that are annotated with:
  • HasPublicStaticIsValidMethod
  • HasPublicStaticValueOfMethod (with String parameter)
  • HasEntityTypeConstant
and implementing EntityId.
  • Constructor Details

    • JandexEntityIdFactory

      public JandexEntityIdFactory()
      Default constructor.
    • JandexEntityIdFactory

      public JandexEntityIdFactory(File... classesDirs)
      Constructor with classes directories. Most likely only used in tests.
      Parameters:
      classesDirs - Directories with class files.
  • Method Details

    • createEntityId

      public EntityId createEntityId(String type, String id)
      Description copied from interface: EntityIdFactory
      Creates an entity id by type and string identifier.
      Specified by:
      createEntityId in interface EntityIdFactory
      Parameters:
      type - Type of the identifier.
      id - Identifier.
      Returns:
      Entity identifier.
    • containsType

      public boolean containsType(String type)
      Description copied from interface: EntityIdFactory
      Verifies if the given type string is a valid one.
      Specified by:
      containsType in interface EntityIdFactory
      Parameters:
      type - Type to be verified.
      Returns:
      TRUE if the factory can create identifiers for the given type.
    • isValid

      public boolean isValid(String type, String id)
      Description copied from interface: EntityIdFactory
      Determines if an identifier of the given type is valid.
      Specified by:
      isValid in interface EntityIdFactory
      Parameters:
      type - Type of the identifier.
      id - Identifier to be verified.
      Returns:
      TRUE if the factory can create and identifier for the given type and value.
    • getIdClasses

      public List<Class<?>> getIdClasses()
      Returns a list of known EntityId classes.
      Returns:
      Entity ID classes.
    • typeConstant

      public EntityType typeConstant(Class<?> entityIdClass)