Class CodeFactory


  • @Service(CodeFactory.class)
    public class CodeFactory
    extends java.lang.Object
    Factory for code snippets used by generators such as wurblets.
    • Constructor Detail

      • CodeFactory

        public CodeFactory()
    • 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 type
        index - 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 attribute
        value - 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 relation
        withinForeignEntity - 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 entity
        backend - 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 backend
        entity - the entity
        index - 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 key
        backend - the backend to create sql code for
        Returns:
        the SQL code