Class MapProperty<E,K,T>

java.lang.Object
org.fastnate.generator.context.Property<E,Map<K,T>>
org.fastnate.generator.context.PluralProperty<E,Map<K,T>,T>
org.fastnate.generator.context.MapProperty<E,K,T>
Type Parameters:
E - The type of the container entity
K - The type of the key of the map
T - The type of the entity inside of the collection

public class MapProperty<E,K,T> extends PluralProperty<E,Map<K,T>,T>
Describes a property of an EntityClass that is a Map.
Author:
Tobias Liefke
  • Field Details

    • keyClass

      private final Class<K> keyClass
      The class of the key of the map.
    • keyEntityClass

      private final EntityClass<K> keyEntityClass
      The description of the key class, null if not an entity.
    • keyConverter

      private final ValueConverter<K> keyConverter
      The converter for the target value, null if not a primitive value.
    • keyColumn

      private final GeneratorColumn keyColumn
      The name of the column that contains the key.
  • Constructor Details

    • MapProperty

      public MapProperty(EntityClass<?> sourceClass, AttributeAccessor attribute, jakarta.persistence.AssociationOverride associationOverride, jakarta.persistence.AttributeOverride attributeOverride)
      Creates a new map property.
      Parameters:
      sourceClass - the description of the current inspected class that contains this property
      attribute - the accessor of the represented attribute
      associationOverride - the configured assocation override
      attributeOverride - the configured attribute override, if we reference an ElementCollection
  • Method Details

    • buildKeyColumn

      private static GeneratorColumn buildKeyColumn(GeneratorTable table, jakarta.persistence.MapKeyColumn keyColumn, String defaultKeyColumn)
    • buildKeyColumn

      private static GeneratorColumn buildKeyColumn(GeneratorTable table, jakarta.persistence.MapKeyJoinColumn keyColumn, String defaultKeyColumn)
    • isMapProperty

      public static boolean isMapProperty(AttributeAccessor attribute)
      Indicates that the given attribute references a map and may be used by an MapProperty.
      Parameters:
      attribute - the attribute to check
      Returns:
      true if an MapProperty may be created for the given attribute
    • createPostInsertStatements

      public void createPostInsertStatements(StatementsWriter writer, E entity) throws IOException
      Description copied from class: Property
      Creates additional SQL statements that are necessary after this property is written (e.g. for mapping tables).
      Overrides:
      createPostInsertStatements in class Property<E,Map<K,T>>
      Parameters:
      writer - the target of the created statements
      entity - the inspected entity
      Throws:
      IOException - if the writer throws one
    • findReferencedEntities

      public Collection<?> findReferencedEntities(E entity)
      Description copied from class: Property
      Finds all entities in the current property, that are referenced.
      Overrides:
      findReferencedEntities in class Property<E,Map<K,T>>
      Parameters:
      entity - the inspected entity
      Returns:
      all referenced entities
    • getValue

      public Map<K,T> getValue(E entity)
      Description copied from class: Property
      Resolves the current value for this property on the given entity.
      Overrides:
      getValue in class Property<E,Map<K,T>>
      Parameters:
      entity - the entity to inspect
      Returns:
      the value, null if entity is null
    • getKeyClass

      public Class<K> getKeyClass()
      The class of the key of the map.
    • getKeyEntityClass

      public EntityClass<K> getKeyEntityClass()
      The description of the key class, null if not an entity.
    • getKeyConverter

      public ValueConverter<K> getKeyConverter()
      The converter for the target value, null if not a primitive value.
    • getKeyColumn

      public GeneratorColumn getKeyColumn()
      The name of the column that contains the key.
      Specified by:
      getKeyColumn in class PluralProperty<E,Map<K,T>,T>
      Returns:
      the key column for map properties resp. the index column for list properties