- java.lang.Object
-
- org.tentackle.model.CodeFactory
-
@Service(CodeFactory.class) public class CodeFactory extends java.lang.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 java.lang.StringcreateBindableAnnotation(Attribute attribute)Creates source code for the @Bindable-annotation.java.lang.StringcreateColumnPostfix(java.lang.String javaType, int index)Creates the column postfix for a given index.
For datatypes mapping to more than one column, the column names get a postfix.java.lang.StringcreateDeclaredJavaType(Relation relation, boolean withinForeignEntity)Creates the declared type of a relation.java.lang.StringcreateGetterName(Attribute attribute)Creates the name of the getter for an attribute.java.lang.StringcreateGetterName(Relation relation)Creates the name of the getter for a relation.java.lang.StringcreateJavaType(Relation relation)Creates the java type of a relation.java.lang.StringcreateMethodArgument(Attribute attribute, java.lang.String value)Creates the source code for a method argument.java.lang.StringcreateSetterName(Attribute attribute)Creates the name of the setter for an attribute.java.lang.StringcreateSetterName(Relation relation)Creates the name of the setter for a relation.java.lang.StringcreateSqlForeignKey(ForeignKey foreignKey, org.tentackle.sql.Backend backend)Creates the foreign key creation sql code.java.lang.StringcreateSqlIndex(org.tentackle.sql.Backend backend, Entity entity, Index index)Creates the SQL code to create an index.java.lang.StringcreateSqlTable(Entity entity, org.tentackle.sql.Backend backend)Creates the table creation sql code.static CodeFactorygetInstance()The singleton.
-
-
-
Method Detail
-
getInstance
public static CodeFactory getInstance()
The singleton.- Returns:
- the singleton
-
createColumnPostfix
public java.lang.String createColumnPostfix(java.lang.String javaType, int index)Creates the column postfix for a given index.
For datatypes mapping to more than one column, the column names get a postfix.- Parameters:
javaType- the java typeindex- the index starting at 0- Returns:
- the postfix, never null
-
createBindableAnnotation
public java.lang.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 java.lang.String createMethodArgument(Attribute attribute, java.lang.String value)
Creates the source code for a method argument.- Parameters:
attribute- the attributevalue- the argument name- Returns:
- the java code
-
createGetterName
public java.lang.String createGetterName(Attribute attribute)
Creates the name of the getter for an attribute.- Parameters:
attribute- the attribute- Returns:
- the getter name
-
createSetterName
public java.lang.String createSetterName(Attribute attribute)
Creates the name of the setter for an attribute.- Parameters:
attribute- the attribute- Returns:
- the setter name
-
createGetterName
public java.lang.String createGetterName(Relation relation)
Creates the name of the getter for a relation.- Parameters:
relation- the relation- Returns:
- the getter name
-
createSetterName
public java.lang.String createSetterName(Relation relation)
Creates the name of the setter for a relation.- Parameters:
relation- the relation- Returns:
- the setter name
-
createDeclaredJavaType
public java.lang.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 java.lang.String createJavaType(Relation relation)
Creates the java type of a relation.- Parameters:
relation- the relation- Returns:
- the java type
-
createSqlTable
public java.lang.String createSqlTable(Entity entity, org.tentackle.sql.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 java.lang.String createSqlIndex(org.tentackle.sql.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 java.lang.String createSqlForeignKey(ForeignKey foreignKey, org.tentackle.sql.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
-
-