Class OMColumnJavaTransformer


  • public class OMColumnJavaTransformer
    extends Object
    Does java related mappings.
    • Constructor Detail

      • OMColumnJavaTransformer

        public OMColumnJavaTransformer()
    • Method Detail

      • setJavaTypeAttribute

        protected void setJavaTypeAttribute​(SourceElement columnElement)
        Sets the javaType attribute of the column element if it is not already set and a default value is set.
        Parameters:
        columnElement - the column element, not null.
      • setJavaNameAttribute

        protected void setJavaNameAttribute​(SourceElement columnElement)
        Sets the javaName attribute of the column element if it is not already set.
        Parameters:
        columnElement - the column element, not null.
      • setFieldNameAttribute

        protected void setFieldNameAttribute​(SourceElement columnElement)
        Sets the fieldName attribute of the column element if it is not already set. The javaName attribute of the column must be set.
        Parameters:
        columnElement - the column element, not null.
      • getDefaultValueWithDefaultSet

        protected String getDefaultValueWithDefaultSet​(JavaType javaType,
                                                       String defaultValue,
                                                       boolean useDatabaseDefaultValue,
                                                       SourceElement columnElement)
                                                throws SourceTransformerException
        Calculates the java default value of a column in case a default value is set.
        Parameters:
        javaType - The java type of the column.
        defaultValue - The default value from the schema.
        useDatabaseDefaultValue - whether the database default value should be used.
        columnElement - the current column element for which the default value should be calculated.
        Returns:
        The java default value.
        Throws:
        SourceTransformerException - if an illegal default value is used.
      • getDefaultValueWithoutDefaultSet

        protected String getDefaultValueWithoutDefaultSet​(JavaType javaType)
                                                   throws SourceTransformerException
        Calculates the java default value of a column in case a default value is not set.
        Parameters:
        javaType - The java type of the column.
        Returns:
        The java default value.
        Throws:
        SourceTransformerException - if the value cannot be found
      • setFieldJavaType

        protected JavaType setFieldJavaType​(SourceElement columnElement,
                                            SchemaType schemaType,
                                            String enumClassName)
                                     throws SourceTransformerException
        Returns the java type of the field representing a database column.
        Parameters:
        columnElement - the column element, not null.
        schemaType - the schema type, not null.
        enumClassName - the class name of the enum, or null if the column is not an enum.
        Returns:
        the java type of the column
        Throws:
        SourceTransformerException - if error in transform
      • setEnumAttributes

        public static String setEnumAttributes​(SourceElement columnElement,
                                               ControllerState controllerState)
        Sets the enumClassName, enumPackage and generateEnum Attributes if either enumValue child elements (xml element enum-value) are present or the enumType attribute is set on the column. Afterwards, the enumClassName attribute contains the unqualified name of the enum, the enumPackage attribute contains the enum package, and the generateEnum attribute contains "true" if the enum needs to be generated. This requires that the javaName attribute is set on the column and that the dbObjectPackage element is set on the table.
        Parameters:
        columnElement - the column element to set the elements in, not null.
        controllerState - the controller state, not null.
        Returns:
        the class name of the enum, or null if the column is not an enum column.