mplates.1.2.source-code.PojoFields.ftl Maven / Gradle / Ivy
<#include "license.ftl">
<@license/>
<#assign object = doc.object>
package ${object.@package}.model.fields;
/**
* A list of tall the attributes of ${object.@name} and their corresponding java.sql.Types value.
* To make his enum portable to GWT, the numeric value of Types is used, here is the legend:
* Types.INTEGER 4
* Types.BIGINT -5
* Types.DATE 91
* Types.BOOLEAN 16
* Types.CHAR 1
* Types.LONGVARCHAR -1
* Types.VARCHAR 12
* Types.DOUBLE 8
* @author Redora
* @see java.sql.Types
*/
public enum ${object.@name}Fields {
id(-5)
,creationDate(91)
,updateDate(91)
<#list object.formScope?children as att>
<#if att?node_type == "element" && att?node_name != "object">
<#if att.description[0]??>
/** ${att.description} */
,${att.@fieldName}<#t>
<#if att?node_name == "boolean">
(16)<#t>
<#elseif att?node_name == "date" || att?node_name == "datetime">
(91)<#t>
<#elseif att?node_name == "enum">
(1)<#t>
<#elseif att?node_name == "integer">
(4)<#t>
<#elseif att?node_name == "long">
(-5)<#t>
<#elseif att?node_name == "string">
<#if att.@maxlength[0]?number > 65000>
(-1)<#t>
<#else>
(12)<#t>
<#elseif att?node_name == "html">
(-1)<#t>
<#elseif att?node_name == "double">
(8)<#t>
<#else>
ERROR, undefined node ${att?node_name}
;<#t>
public int sqlType;
private ${object.@name}Fields(int sqlType) {
this.sqlType = sqlType;
}
/**
* @return Null, or the result of valueOf()
*/
public static ${object.@name}Fields valueOfNullSafe(String value) {
if (value != null) {
return valueOf(value);
}
return null;
}
}