Class CodeFactory


  • @Service(CodeFactory.class)
    public class CodeFactory
    extends 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
      • 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 attribute
        value - 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 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 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 entity
        backend - 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 backend
        entity - the entity
        index - 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 key
        backend - the backend to create sql code for
        Returns:
        the SQL code