public class AttributeImpl extends Object implements Attribute, Comparable<AttributeImpl>
| Constructor and Description |
|---|
AttributeImpl(EntityFactoryImpl factory,
Entity entity,
SourceInfo sourceInfo,
boolean implicit)
Creates an attribute.
|
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(AttributeImpl o) |
ModelException |
createModelException(String message)
Creates a model exception.
|
boolean |
equals(Object obj) |
String |
getApplicationType()
Gets the application specific type.
|
String |
getBindableAnnotation()
Returns the @Bindable-annotation text.
|
String |
getColumnName()
Gets the database column name.
|
DataType |
getDataType()
Gets the data type.
|
DataType |
getEffectiveType()
Gets the effective type exposed to the backend.
If this is an application specific type, the inner type will be returned. |
Entity |
getEntity()
Gets the entity this attribute belongs to.
|
String |
getGetterName()
Gets the getter method name.
|
String |
getInnerName()
Returns the inner type.
|
DataType |
getInnerType()
Gets the innertype for application specific types.
|
String |
getJavaType()
Gets the java type.
Returns the java type with optional generic info. |
String |
getMethodNameSuffix()
Gets the suffix to be used in methodnames.
|
String |
getName()
Gets the name of the element.
|
AttributeOptionsImpl |
getOptions()
Gets the options.
|
ModelElement |
getParent()
Gets the parent element.
|
Relation |
getRelation()
Gets the associated relation.
|
Integer |
getScale()
Gets the scale for numbers with a fraction part.
|
int |
getScaleWithDefault()
Gets the scale width with default 0.
|
String |
getSetterName()
Gets the setter method name.
|
Integer |
getSize()
Gets the column width.
|
int |
getSizeWithDefault()
Gets the column width with default 0.
|
SourceInfo |
getSourceInfo()
Gets the information about the source where this element is defined.
|
AttributeLine |
getSourceLine()
Gets the source line.
|
int |
hashCode() |
boolean |
isImplicit()
Returns whether attribute is implicit and not result of an attribute line configuration.
|
boolean |
isNullable()
Returns whether database column is nullable.
|
void |
parse(Entity entity,
AttributeLine line)
Parses an attribute line.
|
void |
setApplicationType(String applicationType)
Sets the application specific type.
Only allowed DataType.APPLICATION. |
void |
setColumnName(String columnName) |
void |
setDataType(DataType dataType) |
void |
setInnerName(String innerType)
Sets the inner type.
|
void |
setName(String javaName) |
void |
setNullable(Boolean nullable)
Overrides nullable feature.
|
void |
setRelation(Relation relation) |
void |
setScale(Integer scale) |
void |
setSize(Integer size) |
void |
setSourceLine(AttributeLine sourceLine)
Sets the source line.
|
String |
toMethodArgument(String value)
Conberts a given value string to a valid java method argument.
Adds downcasts, if necessary. |
String |
toString() |
void |
validate()
Validates the attribute.
|
public AttributeImpl(EntityFactoryImpl factory, Entity entity, SourceInfo sourceInfo, boolean implicit)
factory - the factory to create the attribute optionsentity - the entity this attribute belongs tosourceInfo - the source infoimplicit - true if implicit attributepublic SourceInfo getSourceInfo()
ModelElementgetSourceInfo in interface ModelElementpublic ModelElement getParent()
ModelElementgetParent in interface ModelElementpublic int compareTo(AttributeImpl o)
compareTo in interface Comparable<AttributeImpl>public boolean isImplicit()
AttributeisImplicit in interface Attributepublic Entity getEntity()
Attributepublic void parse(Entity entity, AttributeLine line) throws ModelException
entity - the entityline - the source lineModelException - if parsing the model failedpublic void setApplicationType(String applicationType) throws ModelException
DataType.APPLICATION.applicationType - the application specific typeModelException - if this is not DataType.APPLICATIONpublic String getApplicationType() throws ModelException
getApplicationType in interface AttributeModelException - if application specific type not set or this is not DataType.APPLICATIONpublic void setInnerName(String innerType) throws ModelException
innerType - the inner typeModelException - if this is neither DataType.APPLICATION nor DataType.BINARYpublic String getInnerName() throws ModelException
getInnerName in interface AttributeDataType.BINARY)ModelException - this is DataType.APPLICATION and inner type not setpublic DataType getInnerType() throws ModelException
getInnerType in interface AttributeModelException - if not DataType.APPLICATION or innertype not a legal DataType.public DataType getEffectiveType() throws ModelException
AttributegetEffectiveType in interface AttributeModelException - if model garbeledpublic String getJavaType() throws ModelException
Examples:
Date Binary<Invoice> MyType<int>
getJavaType in interface AttributeModelException - if type is misconfiguredpublic Relation getRelation()
AttributegetRelation in interface Attributepublic String getName()
ModelElementgetName in interface ModelElementpublic String getColumnName()
AttributegetColumnName in interface Attributepublic DataType getDataType()
AttributegetDataType in interface Attributepublic Integer getSize()
AttributeFor strings this is the maximum number of characters. For numerics this is only a hint for the GUI.
public int getSizeWithDefault()
AttributegetSizeWithDefault in interface Attributepublic Integer getScale()
Attributepublic int getScaleWithDefault()
AttributegetScaleWithDefault in interface Attributepublic AttributeOptionsImpl getOptions()
AttributegetOptions in interface Attributepublic void setColumnName(String columnName)
public void setDataType(DataType dataType)
public void setRelation(Relation relation)
public void setName(String javaName)
public void setScale(Integer scale)
public void setSize(Integer size)
public boolean isNullable()
throws ModelException
AttributeisNullable in interface AttributeModelException - if type is misconfiguredpublic void setNullable(Boolean nullable)
nullable - null to determine from datatypepublic void validate()
throws ModelException
Attributevalidate in interface AttributeModelException - if validation failedpublic AttributeLine getSourceLine()
public void setSourceLine(AttributeLine sourceLine)
sourceLine - the linepublic ModelException createModelException(String message)
Refers to the source line if set, otherwise just the message.
message - the messagepublic String getMethodNameSuffix()
AttributeExample:
"set" + getMethodNameSuffix() would return "setBlah" if the javaName is "blah".
getMethodNameSuffix in interface Attributepublic String getGetterName()
AttributegetGetterName in interface Attributepublic String getSetterName()
AttributegetSetterName in interface Attributepublic String getBindableAnnotation()
AttributegetBindableAnnotation in interface Attributepublic String toMethodArgument(String value)
AttributetoMethodArgument in interface Attributevalue - the value stringTentackle - a domain driven enterprise framework