- java.lang.Object
-
- org.tentackle.model.CodeFactory
-
@Service(CodeFactory.class) public class CodeFactory extends Object
Factory for code snippets used by generators such as wurblets.
-
-
Constructor Summary
Constructors Constructor Description CodeFactory()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description StringcreateBindableAnnotation(Attribute attribute)Creates source code for the @Bindable-annotation.StringcreateDeclaredJavaType(Relation relation, boolean withinForeignEntity)Creates the declared type of a relation.StringcreateGetterName(Attribute attribute)Creates the name of the getter for an attribute.StringcreateGetterName(Relation relation)Creates the name of the getter for a relation.StringcreateJavaType(Relation relation)Creates the java type of a relation.StringcreateMethodArgument(Attribute attribute, String value)Creates the source code for a method argument.StringcreateSetterName(Attribute attribute)Creates the name of the setter for an attribute.StringcreateSetterName(Relation relation)Creates the name of the setter for a relation.StringcreateSqlForeignKey(ForeignKey foreignKey, Backend backend)Creates the foreign key creation sql code.StringcreateSqlIndex(Backend backend, Entity entity, Index index)Creates the SQL code to create an index.StringcreateSqlTable(Entity entity, Backend backend)Creates the table creation sql code.static CodeFactorygetInstance()The singleton.
-
-
-
Method Detail
-
getInstance
public static CodeFactory getInstance()
The singleton.- Returns:
- the singleton
-
createBindableAnnotation
public String createBindableAnnotation(Attribute attribute)
Creates source code for the @Bindable-annotation.- Parameters:
attribute- the attribute- Returns:
- the java code, null if no binding
-
createMethodArgument
public String createMethodArgument(Attribute attribute, String value) throws ModelException
Creates the source code for a method argument.- Parameters:
attribute- the attributevalue- the argument name- Returns:
- the java code
- Throws:
ModelException
-
createGetterName
public String createGetterName(Attribute attribute)
Creates the name of the getter for an attribute.- Parameters:
attribute- the attribute- Returns:
- the getter name
-
createSetterName
public String createSetterName(Attribute attribute)
Creates the name of the setter for an attribute.- Parameters:
attribute- the attribute- Returns:
- the setter name
-
createGetterName
public String createGetterName(Relation relation)
Creates the name of the getter for a relation.- Parameters:
relation- the relation- Returns:
- the getter name
-
createSetterName
public String createSetterName(Relation relation)
Creates the name of the setter for a relation.- Parameters:
relation- the relation- Returns:
- the setter name
-
createDeclaredJavaType
public String createDeclaredJavaType(Relation relation, boolean withinForeignEntity)
Creates the declared type of a relation.- Parameters:
relation- the relationwithinForeignEntity- true if we need the type from within the foreign entity, else from within the relation's entity- Returns:
- the declared java type
-
createJavaType
public String createJavaType(Relation relation)
Creates the java type of a relation.- Parameters:
relation- the relation- Returns:
- the java type
-
createSqlTable
public String createSqlTable(Entity entity, Backend backend) throws ModelException
Creates the table creation sql code.- Parameters:
entity- the entitybackend- the backend to create sql code for- Returns:
- the SQL code
- Throws:
ModelException- if model inconsistent
-
createSqlIndex
public String createSqlIndex(Backend backend, Entity entity, Index index)
Creates the SQL code to create an index.- Parameters:
backend- the database backendentity- the entityindex- the index- Returns:
- the SQL code
-
createSqlForeignKey
public String createSqlForeignKey(ForeignKey foreignKey, Backend backend)
Creates the foreign key creation sql code.- Parameters:
foreignKey- the foreign keybackend- the backend to create sql code for- Returns:
- the SQL code
-
-