- java.lang.Object
-
- org.tentackle.model.impl.EntityFactoryImpl
-
- All Implemented Interfaces:
EntityFactory
public class EntityFactoryImpl extends java.lang.Object implements EntityFactory
The default entity model factory.- Author:
- harald
-
-
Constructor Summary
Constructors Constructor Description EntityFactoryImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.StringconsumePendingComment()Returns the pending comment and consumes it.AttributeImplcreateAttribute(Entity entity, SourceInfo sourceInfo, boolean implicit)Creates an attribute.AttributeOptionsImplcreateAttributeOptions(Attribute attribute, SourceInfo sourceInfo)Creates attribute options.EntitycreateEntity(java.lang.String model, ModelDefaults modelDefaults)Creates an entity from a model source.EntityImplcreateEntity(SourceInfo sourceInfo)Creates an empty entity.EntityOptionsImplcreateEntityOptions(Entity entity, SourceInfo sourceInfo)Creates entity options.IndexImplcreateIndex(Entity entity, SourceInfo sourceInfo)Creates an index.IndexAttributeImplcreateIndexAttribute(Index index)Creates an index attribute.RelationImplcreateRelation(Entity entity, SourceInfo sourceInfo)Creates a relation.java.util.Collection<org.tentackle.sql.Backend>getBackends()Gets the backends to validate the model against.protected voidprocessAttribute(EntityImpl entity, AttributeLine line)Processes an attribute line.protected voidprocessAttributeOption(EntityImpl entity, OptionLine line)Processes an attribute option line.protected voidprocessConfiguration(EntityImpl entity, ConfigurationLine line)Processes a configuration line.protected voidprocessGlobalOptions(EntityImpl entity, GlobalOptionLine line)Processes a global option line.protected voidprocessIndexConfiguration(EntityImpl entity, ConfigurationLine line)Processes an index configuration line.
Requires the attribute already processed.protected voidprocessRelation(EntityImpl entity, RelationLine line)Processes a relation line.protected voidprocessRelationOption(EntityImpl entity, OptionLine line)Processes a relation option line.voidsetBackends(java.util.Collection<org.tentackle.sql.Backend> backends)Sets the backends to validate the model against.protected voidsetPendingComment(java.lang.String commentLine)Adds a pending comment line.
-
-
-
Method Detail
-
getBackends
public java.util.Collection<org.tentackle.sql.Backend> getBackends()
Description copied from interface:EntityFactoryGets the backends to validate the model against.- Specified by:
getBackendsin interfaceEntityFactory- Returns:
- the backends, empty if check is disabled, never null
-
setBackends
public void setBackends(java.util.Collection<org.tentackle.sql.Backend> backends)
Description copied from interface:EntityFactorySets the backends to validate the model against.- Specified by:
setBackendsin interfaceEntityFactory- Parameters:
backends- the backends, null to disable check
-
createEntity
public EntityImpl createEntity(SourceInfo sourceInfo)
Description copied from interface:EntityFactoryCreates an empty entity.- Specified by:
createEntityin interfaceEntityFactory- Parameters:
sourceInfo- source information, null if none- Returns:
- the created entity
-
createAttribute
public AttributeImpl createAttribute(Entity entity, SourceInfo sourceInfo, boolean implicit)
Description copied from interface:EntityFactoryCreates an attribute.- Specified by:
createAttributein interfaceEntityFactory- Parameters:
entity- the entity this attribute belongs tosourceInfo- source information, null if noneimplicit- true if implicit attribute- Returns:
- the created attribute
-
createAttributeOptions
public AttributeOptionsImpl createAttributeOptions(Attribute attribute, SourceInfo sourceInfo)
Description copied from interface:EntityFactoryCreates attribute options.- Specified by:
createAttributeOptionsin interfaceEntityFactory- Parameters:
attribute- the attributesourceInfo- source information, null if none- Returns:
- the created options
-
createEntityOptions
public EntityOptionsImpl createEntityOptions(Entity entity, SourceInfo sourceInfo)
Description copied from interface:EntityFactoryCreates entity options.- Specified by:
createEntityOptionsin interfaceEntityFactory- Parameters:
entity- the entitysourceInfo- source information, null if none- Returns:
- the created options
-
createIndex
public IndexImpl createIndex(Entity entity, SourceInfo sourceInfo)
Description copied from interface:EntityFactoryCreates an index.- Specified by:
createIndexin interfaceEntityFactory- Parameters:
entity- the entity this index belongs tosourceInfo- source information, null if none- Returns:
- the created index
-
createIndexAttribute
public IndexAttributeImpl createIndexAttribute(Index index)
Description copied from interface:EntityFactoryCreates an index attribute.- Specified by:
createIndexAttributein interfaceEntityFactory- Parameters:
index- the index- Returns:
- the created index attribute
-
createRelation
public RelationImpl createRelation(Entity entity, SourceInfo sourceInfo)
Description copied from interface:EntityFactoryCreates a relation.- Specified by:
createRelationin interfaceEntityFactory- Parameters:
entity- the entity this relation belongs tosourceInfo- source information, null if none- Returns:
- the created relation
-
createEntity
public Entity createEntity(java.lang.String model, ModelDefaults modelDefaults) throws ModelException
Description copied from interface:EntityFactoryCreates an entity from a model source.- Specified by:
createEntityin interfaceEntityFactory- Parameters:
model- the model sourcemodelDefaults- the model defaults, null if none- Returns:
- the created entity
- Throws:
ModelException- if parsing the model failed
-
processConfiguration
protected void processConfiguration(EntityImpl entity, ConfigurationLine line) throws ModelException
Processes a configuration line.- Parameters:
entity- the entityline- the configuration line- Throws:
ModelException- if processing failed
-
processIndexConfiguration
protected void processIndexConfiguration(EntityImpl entity, ConfigurationLine line)
Processes an index configuration line.
Requires the attribute already processed.- Parameters:
entity- the entityline- the configuration line
-
processGlobalOptions
protected void processGlobalOptions(EntityImpl entity, GlobalOptionLine line) throws ModelException
Processes a global option line.- Parameters:
entity- the entityline- the global option line- Throws:
ModelException- if processing failed
-
processAttributeOption
protected void processAttributeOption(EntityImpl entity, OptionLine line) throws ModelException
Processes an attribute option line.- Parameters:
entity- the entityline- the attribute option line- Throws:
ModelException- if processing failed
-
processRelationOption
protected void processRelationOption(EntityImpl entity, OptionLine line) throws ModelException
Processes a relation option line.- Parameters:
entity- the entityline- the attribute option line- Throws:
ModelException- if processing failed
-
processAttribute
protected void processAttribute(EntityImpl entity, AttributeLine line) throws ModelException
Processes an attribute line.- Parameters:
entity- the entityline- the attribute line- Throws:
ModelException- if processing failed
-
processRelation
protected void processRelation(EntityImpl entity, RelationLine line) throws ModelException
Processes a relation line.- Parameters:
entity- the entityline- the relation line- Throws:
ModelException- if processing failed
-
setPendingComment
protected void setPendingComment(java.lang.String commentLine)
Adds a pending comment line.- Parameters:
commentLine- the comment line
-
consumePendingComment
protected java.lang.String consumePendingComment()
Returns the pending comment and consumes it.- Returns:
- the pending comment, null if none
-
-