Interface EntityDefinition


public interface EntityDefinition
Specifies an entity definition.
  • Field Details

    • STRICT_FOREIGN_KEYS

      static final PropertyValue<Boolean> STRICT_FOREIGN_KEYS
      Specifies whether it should be possible to define foreign keys referencing entities that have not been defined, this can be disabled in cases where entities have circular references.
      Value type: Boolean
      Default value: true
    • OPTIMISTIC_LOCKING

      static final PropertyValue<Boolean> OPTIMISTIC_LOCKING
      Specifies whether optimistic locking should be enabled by default for entities
      Value type: Boolean
      Default value: true
  • Method Details

    • entityType

      EntityType entityType()
      Returns:
      the entity type
    • tableName

      String tableName()
      Returns:
      the name of the underlying table, with schema prefix if applicable
    • conditionProvider

      ConditionProvider conditionProvider(ConditionType conditionType)
      Returns the ConditionProvider associated with the given type
      Parameters:
      conditionType - the condition type
      Returns:
      the condition provider associated with the given type
      Throws:
      IllegalArgumentException - in case no ConditionProvider is associated with the given conditionType
    • validator

      EntityValidator validator()
      Returns:
      the validator for this entity type
    • exists

      Predicate<Entity> exists()
      The default exists predicate returns true if the entity has a non-null original primary key, which is a best guess about an entity existing in a database.
      Returns:
      the predicate to use to check if an entity of this type exists in the database
    • caption

      String caption()
      Returns:
      the caption to use when presenting entities of this type
    • description

      String description()
      Returns:
      the entity description
    • smallDataset

      boolean smallDataset()
      Returns:
      true if the underlying table is small enough for displaying the contents in a combo box
    • readOnly

      boolean readOnly()
      Returns:
      true if this entity type is read only
    • optimisticLocking

      boolean optimisticLocking()
      Returns:
      true if optimistic locking should be used during updates
    • orderBy

      Optional<OrderBy> orderBy()
      Returns:
      the default order by clause to use when querying entities of this type, an empty Optional if none is available
    • selectTableName

      String selectTableName()
      Returns:
      the name of the table to use when selecting entities of this type
    • selectQuery

      Optional<SelectQuery> selectQuery()
      Returns:
      the select query to use when selecting entities of this type, an empty Optional if none is available
    • stringFactory

      Function<Entity,String> stringFactory()
      Returns:
      the object responsible for providing toString values for this entity type
    • comparator

      Comparator<Entity> comparator()
      Returns:
      the comparator used when comparing this entity type to other entities
    • attributes

      Returns:
      the EntityDefinition.Attributes instance
    • columns

      Returns:
      the EntityDefinition.Columns instance
    • foreignKeys

      Returns:
      the EntityDefinition.ForeignKeys instance
    • primaryKey

      Returns:
      the EntityDefinition.PrimaryKey instance
    • backgroundColorProvider

      ColorProvider backgroundColorProvider()
      Returns the background color provider, never null
      Returns:
      the background color provider
    • foregroundColorProvider

      ColorProvider foregroundColorProvider()
      Returns the foreground color provider, never null
      Returns:
      the foreground color provider
    • entity

      Entity entity()
      Creates a new Entity instance based on this definition
      Returns:
      a new Entity instance
    • entity

      Entity entity(Map<Attribute<?>,Object> values)
      Creates a new Entity instance based on this definition
      Parameters:
      values - the values
      Returns:
      a new Entity instance
      Throws:
      IllegalArgumentException - in case any of the value attributes are not part of the entity.
    • entity

      Entity entity(Map<Attribute<?>,Object> values, Map<Attribute<?>,Object> originalValues)
      Creates a new Entity instance based on this definition
      Parameters:
      values - the values
      originalValues - the original values
      Returns:
      a new Entity instance
      Throws:
      IllegalArgumentException - in case any of the value attributes are not part of the entity.
    • primaryKey

      <T> Entity.Key primaryKey(T value)
      Creates a new Entity.Key instance based on this definition, initialised with the given value
      Type Parameters:
      T - the key value type
      Parameters:
      value - the key value, assuming a single value key
      Returns:
      a new Entity.Key instance
      Throws:
      IllegalStateException - in case the given primary key is a composite key
      IllegalArgumentException - in case the value is not of the correct type