Interface Attribute

All Superinterfaces:
ModelElement
All Known Implementing Classes:
AttributeImpl

public interface Attribute extends ModelElement
An attribute.

Each attribute corresponds to a database column.

Author:
harald
  • Method Details

    • getEntity

      Entity getEntity()
      Gets the entity this attribute belongs to.
      Returns:
      the entity
    • getColumnName

      String getColumnName()
      Gets the column name.
      This is the model's column name.
      According to the DataType, an attribute may be mapped to more than one database column.
      Returns:
      the column name (always in lowercase)
      See Also:
    • getColumnName

      String getColumnName(Backend backend, int columnIndex) throws ModelException
      Gets the database column name.
      For datatype with only one column, this is usually the same as the model's column name.
      Parameters:
      columnIndex - the column index according to the DataType.
      Returns:
      the column name used by the database
      Throws:
      ModelException
      See Also:
    • getDataType

      DataType<?> getDataType()
      Gets the model's data type.
      Returns:
      the data type
    • getInnerTypeName

      String getInnerTypeName() throws ModelException
      Gets the inner type name.
      This is either the generic inner type or the wrapped type of Convertible types.
      Returns:
      the inner type name
      Throws:
      ModelException - if not an application type or innername not set
    • getSize

      Integer getSize()
      Gets the column width.

      For strings this is the maximum number of characters. For numerics this is only a hint for the GUI.

      Returns:
      the size, null if not set
    • getScale

      Integer getScale()
      Gets the scale for numbers with a fraction part.
      Returns:
      the scale, null if not set
    • getOptions

      AttributeOptions getOptions()
      Gets the options.
      Returns:
      the options
    • isImplicit

      boolean isImplicit()
      Returns whether attribute is implicit and not result of an attribute line configuration.
      Returns:
      true if implicit
    • isHidden

      boolean isHidden()
      Returns whether attribute is hidden and not part of the interface.
      Returns:
      true if hidden
    • isConvertible

      boolean isConvertible()
      Returns whether the attribute's type implements a Convertible.
      Returns:
      true if Convertible
    • createEmbedded

      Attribute createEmbedded(Entity embeddingEntity, String pathName, String columnName)
      Creates an embedded copy of this attribute.
      Parameters:
      embeddingEntity - the embedding entity
      pathName - the logical pathname
      columnName - the new column name
      Returns:
      the created attribute
    • getEmbeddingEntity

      Entity getEmbeddingEntity()
      Gets the embedding entity.
      Please notice that the embedding entity is determined by the specific relation, and isEmbedded() just means that the attribute is part of an embeddable entity.
      Returns:
      the embedding entity, null if not an embedded attribute
    • getEmbeddingPath

      List<Entity> getEmbeddingPath()
      Gets the path of embedding entities.
      The first entity is non-embedded.
      Returns:
      the embedding path (never empty), null if attribute is not embedded
    • getPathName

      String getPathName()
      Gets the pathname.
      The pathname is identical to the java name for non-embedded entities.
      For embedded entities, the pathname consists of the dotted path from the parent entity to the embedded attribute.
      Returns:
      the pathname
    • isEmbedded

      boolean isEmbedded()
      Returns whether the attribute belongs to an embedded entity.
      Returns:
      true if embedded
    • getApplicationTypeName

      String getApplicationTypeName() throws ModelException
      Gets the name of the application specific type, if a Convertible type.
      Returns:
      the application specific type, never null or empty
      Throws:
      ModelException - if this is not a Convertible type
    • getInnerDataType

      DataType<?> getInnerDataType() throws ModelException
      Gets the inner datatype exposed to the backend if Convertible.
      Returns:
      the inner type for the backend
      Throws:
      ModelException - if not a Convertible
    • getEffectiveDataType

      DataType<?> getEffectiveDataType() throws ModelException
      Gets the effective type exposed to the backend.
      If this is an application specific type, the inner type will be returned.
      Returns:
      the effective data type
      Throws:
      ModelException - if model garbled
    • getJavaType

      String getJavaType() throws ModelException
      Gets the java type.
      Returns the java type with optional generic info.

      Examples:

       Date
       Binary<Invoice>
       MyType;
       
      Returns:
      the type string
      Throws:
      ModelException - if type is misconfigured
    • isNullable

      boolean isNullable() throws ModelException
      Returns whether database column is nullable.
      Returns:
      true if WITH NULL, false if NOT NULL
      Throws:
      ModelException - if type is misconfigured
    • getRelation

      Relation getRelation()
      Gets the associated relation.
      Returns:
      the relation, null if none
    • validate

      void validate() throws ModelException
      Validates the attribute.
      Throws:
      ModelException - if validation failed
    • getMethodNameSuffix

      String getMethodNameSuffix()
      Gets the suffix to be used in methodnames.

      Example:

       "set" + getMethodNameSuffix() would return "setBlah" if the javaName is "blah".
       
      Returns:
      the suffix
    • getGetterName

      String getGetterName()
      Gets the getter method name.
      Returns:
      the getter
    • getSetterName

      String getSetterName()
      Gets the setter method name.
      Returns:
      the setter
    • getBindableAnnotation

      String getBindableAnnotation()
      Returns the @Bindable-annotation text.
      Returns:
      the annotation text, null if none
    • toMethodArgument

      String toMethodArgument(String value) throws ModelException
      Converts a given value string to a valid java method argument.
      Adds a downcast, if necessary.
      Parameters:
      value - the value string
      Returns:
      the method argument string
      Throws:
      ModelException