templates.table.column.TableFieldImpl.ftl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of autoplsp Show documentation
Show all versions of autoplsp Show documentation
Maven plugin to generate Java classes from StoredProcedure and Functions in Database
<#if header>
/*
* Copyright (C) 2019 Yadickson Soto
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
package ${javaPackage}.${tableFolderName}.column;
<#assign importList = ["${javaPackage}.${tableFolderName}.column.type.FieldType", "org.springframework.stereotype.Component"]>
<#if field.type == 'DATE'>
<#assign importList = importList + ["java.util.Date"]>
<#list importSort(importList) as import>
<#if previousImportMatch?? && !import?starts_with(previousImportMatch)>
import ${import};
<#assign previousImportMatch = import?keep_before_last(".") >
<#if importList?has_content>
<#if documentation>
/**
* Class definition for ${table.name} - ${field.name}.
*
* @author @GENERATOR.NAME@
* @version @GENERATOR.VERSION@
*/
@Component
final class ${table.propertyName}${field.propertyName}Impl implements ${table.propertyName}${field.propertyName} {
<#if documentation>
/**
* Field type.
*/
private static final FieldType ${table.name}_${field.name}_TYPE = FieldType.${field.type};
<#if documentation>
/**
* Field position.
*/
private static final int ${table.name}_${field.name}_POSITION = ${field.position};
<#if field.type == 'STRING' || field.type == 'NUMERIC' >
<#if documentation>
/**
* Field minSize.
*/
private static final int ${table.name}_${field.name}_MIN_SIZE = <#if field.minSize??>${field.minSize}<#else>0;
<#if documentation>
/**
* Field maxSize.
*/
private static final int ${table.name}_${field.name}_MAX_SIZE = <#if field.maxSize??>${field.maxSize}<#else>Integer.MAX_VALUE;
<#if documentation>
/**
* Field notNull.
*/
private static final boolean ${table.name}_${field.name}_NOT_NULL = ${field.notNull?c};
<#if field.type == 'STRING' || field.type == 'NUMERIC' || field.type == 'DATE'>
<#if documentation>
/**
* Field defaultValue.
*/
private static final <#if field.type == 'STRING'><#if field.charUsed == 'BYTE'>byte[]<#else>String<#elseif field.type == 'NUMERIC'>Number<#elseif field.type == 'DATE'>Date<#else>Object ${table.name}_${field.name}_DEFAULT_VALUE = <#if field.defaultValue??><#if field.type == 'STRING'>"${field.defaultValue}"<#if field.charUsed == 'BYTE'>.getBytes("${encode}")<#elseif field.type == 'NUMERIC'>${field.defaultValue}<#elseif field.type == 'DATE'>new Date()<#else>null;
<#if documentation>
/**
* @return the type
*/
@Override
public FieldType getType() {
return ${table.name}_${field.name}_TYPE;
}
<#if documentation>
/**
* @return the position
*/
@Override
public int getPosition() {
return ${table.name}_${field.name}_POSITION;
}
<#if field.type == 'STRING' || field.type == 'NUMERIC' >
<#if documentation>
/**
* @return the minSize
*/
@Override
public int getMinSize() {
return ${table.name}_${field.name}_MIN_SIZE;
}
<#if field.charUsed??>
<#if field.charUsed == 'BYTE' >
<#if documentation>
/**
* @return the maxByteSize
*/
@Override
public int getMaxByteSize() {
return ${table.name}_${field.name}_MAX_SIZE;
}
<#elseif field.charUsed == 'CHAR'>
<#if documentation>
/**
* @return the maxCharSize
*/
@Override
public int getMaxCharSize() {
return ${table.name}_${field.name}_MAX_SIZE;
}
<#elseif field.type == 'NUMERIC'>
<#if documentation>
/**
* @return the maxSize
*/
@Override
public int getMaxSize() {
return ${table.name}_${field.name}_MAX_SIZE;
}
<#if documentation>
/**
* @return the notNull
*/
@Override
public Boolean getNotNull() {
return ${table.name}_${field.name}_NOT_NULL;
}
<#if field.type == 'STRING' || field.type == 'NUMERIC' || field.type == 'DATE'>
<#if documentation>
/**
* @return the defaultValue
*/
@Override
public <#if field.type == 'STRING'><#if field.charUsed == 'BYTE'>byte[]<#else>String<#elseif field.type == 'NUMERIC'>Number<#elseif field.type == 'DATE'>Date<#else>Object getDefaultValue() {
return ${table.name}_${field.name}_DEFAULT_VALUE;
}
}