java.lang.Object
org.tentackle.model.impl.AttributeImpl
- All Implemented Interfaces:
Cloneable,Comparable<AttributeImpl>,Attribute,ModelElement
public class AttributeImpl
extends Object
implements Attribute, Comparable<AttributeImpl>, Cloneable
Attribute implementation.
- Author:
- harald
-
Constructor Summary
ConstructorsConstructorDescriptionAttributeImpl(EntityFactoryImpl factory, Entity entity, SourceInfo sourceInfo, boolean implicit) Creates an attribute.AttributeImpl(EntityFactoryImpl factory, Entity entity, SourceInfo sourceInfo, boolean implicit, AttributeOptionsImpl options) Creates an attribute. -
Method Summary
Modifier and TypeMethodDescriptionprotected AttributeImplclone()Clones an attribute.
The method is protected, sincecreateEmbedded(Entity, String, String)should be used instead, which invokesclone().intcreateEmbedded(Entity embeddingEntity, String pathName, String columnName) Creates an embedded copy of this attribute.createModelException(String message) Creates a model exception.booleanGets the name of the application specific type, if a Convertible type.Returns the @Bindable-annotation text.Gets the column name.
This is the model's column name.
According to theDataType, an attribute may be mapped to more than one database column.getColumnName(Backend backend, int columnIndex) Gets the database column name.
For datatype with only one column, this is usually the same as the model's column name.DataType<?> Gets the model's data type.DataType<?> Gets the effective type exposed to the backend.
If this is an application specific type, the inner type will be returned.Gets the embedding entity.
Please notice that the embedding entity is determined by the specific relation, andAttribute.isEmbedded()just means that the attribute is part of an embeddable entity.Gets the path of embedding entities.
The first entity is non-embedded.Gets the entity this attribute belongs to.Gets the getter method name.DataType<?> Gets the inner datatype exposed to the backend if Convertible.Gets the inner type name.
This is either the generic inner type or the wrapped type of Convertible types.Gets the java type.
Returns the java type with optional generic info.Gets the suffix to be used in methodnames.getName()Gets the name of the element.Gets the options.intGets the ordinal along the inheritance path.Gets the parent element.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.Gets the associated relation.getScale()Gets the scale for numbers with a fraction part.Gets the setter method name.getSize()Gets the column width.Gets the information about the source where this element is defined.Gets the source line.inthashCode()booleanReturns whether the attribute's type implements a Convertible.booleanReturns whether the attribute belongs to an embedded entity.booleanisHidden()Returns whether attribute is hidden and not part of the interface.booleanReturns whether attribute is implicit and not result of an attribute line configuration.booleanReturns whether database column is nullable.voidparse(Entity entity, AttributeLine line) Parses an attribute line.voidsetApplicationTypeName(String applicationTypeName) Sets the application specific type if Convertible.voidsetColumnName(String columnName) voidsetDataType(DataType<?> dataType) voidsetInnerTypeName(String innerTypeName) Sets the inner type name.voidvoidsetNullable(Boolean nullable) Overrides nullable feature.voidsetOrdinal(int ordinal) voidsetRelation(Relation relation) voidvoidvoidsetSourceLine(AttributeLine sourceLine) Sets the source line.toMethodArgument(String value) Converts a given value string to a valid java method argument.
Adds a downcast, if necessary.toString()voidvalidate()Validates the attribute.
-
Constructor Details
-
AttributeImpl
public AttributeImpl(EntityFactoryImpl factory, Entity entity, SourceInfo sourceInfo, boolean implicit, AttributeOptionsImpl options) Creates an attribute.- Parameters:
factory- the factory to create the attribute optionsentity- the entity this attribute belongs tosourceInfo- the source infoimplicit- true if implicit attributeoptions- the attribute's options, null to create from source info
-
AttributeImpl
public AttributeImpl(EntityFactoryImpl factory, Entity entity, SourceInfo sourceInfo, boolean implicit) Creates an attribute.- Parameters:
factory- the factory to create the attribute optionsentity- the entity this attribute belongs tosourceInfo- the source infoimplicit- true if implicit attribute
-
-
Method Details
-
createEmbedded
Description copied from interface:AttributeCreates an embedded copy of this attribute.- Specified by:
createEmbeddedin interfaceAttribute- Parameters:
embeddingEntity- the embedding entitypathName- the logical pathnamecolumnName- the new column name- Returns:
- the created attribute
-
clone
Clones an attribute.
The method is protected, sincecreateEmbedded(Entity, String, String)should be used instead, which invokesclone(). -
getSourceInfo
Description copied from interface:ModelElementGets the information about the source where this element is defined.- Specified by:
getSourceInfoin interfaceModelElement- Returns:
- the source info
-
getParent
Description copied from interface:ModelElementGets the parent element.- Specified by:
getParentin interfaceModelElement- Returns:
- the parent, null if none
-
hashCode
public int hashCode() -
equals
-
compareTo
- Specified by:
compareToin interfaceComparable<AttributeImpl>
-
isImplicit
public boolean isImplicit()Description copied from interface:AttributeReturns whether attribute is implicit and not result of an attribute line configuration.- Specified by:
isImplicitin interfaceAttribute- Returns:
- true if implicit
-
isHidden
public boolean isHidden()Description copied from interface:AttributeReturns whether attribute is hidden and not part of the interface. -
getEntity
Description copied from interface:AttributeGets the entity this attribute belongs to. -
getOrdinal
public int getOrdinal()Description copied from interface:ModelElementGets the ordinal along the inheritance path.- Specified by:
getOrdinalin interfaceModelElement- Returns:
- the ordinal, starting at 0
-
setOrdinal
public void setOrdinal(int ordinal) -
parse
Parses an attribute line.- Parameters:
entity- the entityline- the source line- Throws:
ModelException- if parsing the model failed
-
isConvertible
public boolean isConvertible()Description copied from interface:AttributeReturns whether the attribute's type implements a Convertible.- Specified by:
isConvertiblein interfaceAttribute- Returns:
- true if Convertible
-
isEmbedded
public boolean isEmbedded()Description copied from interface:AttributeReturns whether the attribute belongs to an embedded entity.- Specified by:
isEmbeddedin interfaceAttribute- Returns:
- true if embedded
-
getEmbeddingEntity
Description copied from interface:AttributeGets the embedding entity.
Please notice that the embedding entity is determined by the specific relation, andAttribute.isEmbedded()just means that the attribute is part of an embeddable entity.- Specified by:
getEmbeddingEntityin interfaceAttribute- Returns:
- the embedding entity, null if not an embedded attribute
-
getEmbeddingPath
Description copied from interface:AttributeGets the path of embedding entities.
The first entity is non-embedded.- Specified by:
getEmbeddingPathin interfaceAttribute- Returns:
- the embedding path (never empty), null if attribute is not embedded
-
getPathName
Description copied from interface:AttributeGets 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.- Specified by:
getPathNamein interfaceAttribute- Returns:
- the pathname
-
setApplicationTypeName
Sets the application specific type if Convertible.- Parameters:
applicationTypeName- the name of the application specific type
-
getApplicationTypeName
Description copied from interface:AttributeGets the name of the application specific type, if a Convertible type.- Specified by:
getApplicationTypeNamein interfaceAttribute- Returns:
- the application specific type, never null or empty
- Throws:
ModelException- if this is not a Convertible type
-
setInnerTypeName
Sets the inner type name.- Parameters:
innerTypeName- the name of the inner type- Throws:
ModelException- if datatype is Convertible and the inner type is not supported or inner type not applicable to datatype
-
getInnerTypeName
Description copied from interface:AttributeGets the inner type name.
This is either the generic inner type or the wrapped type of Convertible types.- Specified by:
getInnerTypeNamein interfaceAttribute- Returns:
- the inner type name
- Throws:
ModelException- if not an application type or innername not set
-
getInnerDataType
Description copied from interface:AttributeGets the inner datatype exposed to the backend if Convertible.- Specified by:
getInnerDataTypein interfaceAttribute- Returns:
- the inner type for the backend
- Throws:
ModelException- if not a Convertible
-
getEffectiveDataType
Description copied from interface:AttributeGets the effective type exposed to the backend.
If this is an application specific type, the inner type will be returned.- Specified by:
getEffectiveDataTypein interfaceAttribute- Returns:
- the effective data type
- Throws:
ModelException- if model garbled
-
getJavaType
Description copied from interface:AttributeGets the java type.
Returns the java type with optional generic info.Examples:
Date Binary<Invoice> MyType;
- Specified by:
getJavaTypein interfaceAttribute- Returns:
- the type string
- Throws:
ModelException- if type is misconfigured
-
getRelation
Description copied from interface:AttributeGets the associated relation.- Specified by:
getRelationin interfaceAttribute- Returns:
- the relation, null if none
-
getName
Description copied from interface:ModelElementGets the name of the element.- Specified by:
getNamein interfaceModelElement- Returns:
- the name
-
getColumnName
Description copied from interface:AttributeGets the column name.
This is the model's column name.
According to theDataType, an attribute may be mapped to more than one database column.- Specified by:
getColumnNamein interfaceAttribute- Returns:
- the column name (always in lowercase)
- See Also:
-
getColumnName
Description copied from interface:AttributeGets the database column name.
For datatype with only one column, this is usually the same as the model's column name.- Specified by:
getColumnNamein interfaceAttribute- Parameters:
columnIndex- the column index according to theDataType.- Returns:
- the column name used by the database
- Throws:
ModelException- See Also:
-
getDataType
Description copied from interface:AttributeGets the model's data type.- Specified by:
getDataTypein interfaceAttribute- Returns:
- the data type
-
getSize
Description copied from interface:AttributeGets the column width.For strings this is the maximum number of characters. For numerics this is only a hint for the GUI.
-
getScale
Description copied from interface:AttributeGets the scale for numbers with a fraction part. -
getOptions
Description copied from interface:AttributeGets the options.- Specified by:
getOptionsin interfaceAttribute- Returns:
- the options
-
setColumnName
-
setDataType
-
setRelation
-
setName
-
setScale
-
setSize
-
isNullable
Description copied from interface:AttributeReturns whether database column is nullable.- Specified by:
isNullablein interfaceAttribute- Returns:
- true if WITH NULL, false if NOT NULL
- Throws:
ModelException- if type is misconfigured
-
setNullable
Overrides nullable feature.- Parameters:
nullable- null to determine from datatype
-
toString
-
validate
Description copied from interface:AttributeValidates the attribute.- Specified by:
validatein interfaceAttribute- Throws:
ModelException- if validation failed
-
getSourceLine
Gets the source line.- Returns:
- the line
-
setSourceLine
Sets the source line.- Parameters:
sourceLine- the line
-
createModelException
Creates a model exception.Refers to the source line if set, otherwise just the message.
- Parameters:
message- the message- Returns:
- the exception
-
getMethodNameSuffix
Description copied from interface:AttributeGets the suffix to be used in methodnames.Example:
"set" + getMethodNameSuffix() would return "setBlah" if the javaName is "blah".
- Specified by:
getMethodNameSuffixin interfaceAttribute- Returns:
- the suffix
-
getGetterName
Description copied from interface:AttributeGets the getter method name.- Specified by:
getGetterNamein interfaceAttribute- Returns:
- the getter
-
getSetterName
Description copied from interface:AttributeGets the setter method name.- Specified by:
getSetterNamein interfaceAttribute- Returns:
- the setter
-
getBindableAnnotation
Description copied from interface:AttributeReturns the @Bindable-annotation text.- Specified by:
getBindableAnnotationin interfaceAttribute- Returns:
- the annotation text, null if none
-
toMethodArgument
Description copied from interface:AttributeConverts a given value string to a valid java method argument.
Adds a downcast, if necessary.- Specified by:
toMethodArgumentin interfaceAttribute- Parameters:
value- the value string- Returns:
- the method argument string
- Throws:
ModelException
-