templates.domain.OUTImpl.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}.${domainFolderName};
<#assign importList = []>
<#if serialization>
<#assign importList = importList + ["java.io.Serializable"]>
<#if jsonNonNull>
<#assign importList = importList + ["com.fasterxml.jackson.annotation.JsonInclude"]>
<#list proc.outputParameters as parameter>
<#if parameter.date>
<#assign importList = importList + ["java.util.Date"]>
<#if utilFolderName != domainFolderName>
<#assign importList = importList + ["${javaPackage}.${utilFolderName}.${prefixUtilityName}SafeDate"]>
<#if parameter.blob>
<#assign importSafeByteArray = 1>
<#if utilFolderName != domainFolderName>
<#assign importList = importList + ["${javaPackage}.${utilFolderName}.${prefixUtilityName}SafeByteArray"]>
<#list proc.outputParameters as parameter>
<#if parameter.resultSet || parameter.returnResultSet>
<#if cursorFolderName != domainFolderName>
<#assign importList = importList + ["${javaPackage}.${cursorFolderName}.${parameter.javaTypeName}"]>
<#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>
/**
* Output parameters for <#if proc.function>function<#else>stored procedure.
*
* ${proc.fullName}
*
* @author @GENERATOR.NAME@
* @version @GENERATOR.VERSION@
*/
<#if jsonNonNull>
@JsonInclude(JsonInclude.Include.NON_NULL)
final class ${proc.className}OUTImpl implements${'\n'} ${proc.className}OUT<#if serialization>,${'\n'} Serializable {
<#if serialization>
<#if documentation>
/**
* Serialization.
*/
static final long serialVersionUID = 1L;
<#list proc.outputParameters as parameter>
<#if documentation>
/**
* Output parameter ${parameter.name}.
*
* ${proc.fullName}
*/
private <#if fullConstructor>final <#if parameter.resultSet || parameter.returnResultSet>java.util.List<${parameter.javaTypeName}><#else>${parameter.javaTypeName} ${parameter.fieldName}${proc.className}<#if !fullConstructor> = null;
<#if !fullConstructor>
<#if documentation>
/**
* Class Constructor ${proc.className}OUTImpl.
*
*/
public ${proc.className}OUTImpl() {
}
<#if documentation>
/**
* Class Constructor ${proc.className}OUTImpl.
*
* @param ${proc.className}OUT out${proc.className}Instance
*/
public ${proc.className}OUTImpl(final ${proc.className}OUT out${proc.className}Instance) {
<#if fullConstructor>
this(${'\n'} <#list proc.outputParameters as parameter2>out${proc.className}Instance.get${parameter2.propertyName}()<#sep>,${'\n'} ${'\n'} );
<#else>
<#list proc.outputParameters as parameter2>
this.set${parameter2.propertyName}(out${proc.className}Instance.get${parameter2.propertyName}());
}
<#if fullConstructor>
<#if documentation>
/**
* Class constructor ${proc.className}OUT.
*
* ${proc.fullName}
*
<#list proc.outputParameters as parameter>
* @param ${parameter.fieldName} set value of ${parameter.name}
*/
public ${proc.className}OUTImpl(${'\n'} <#list proc.outputParameters as parameter>final <#if parameter.resultSet || parameter.returnResultSet>java.util.List<${parameter.javaTypeName}><#else>${parameter.javaTypeName} ${parameter.fieldName}<#sep>,${'\n'} ${'\n'} ) {
<#list proc.outputParameters as parameter>
<#if parameter.date>
this.${parameter.fieldName}${proc.className} = ${prefixUtilityName}SafeDate.process(${parameter.fieldName});
<#elseif parameter.blob>
this.${parameter.fieldName}${proc.className} = ${prefixUtilityName}SafeByteArray.process(${parameter.fieldName});
<#else>
this.${parameter.fieldName}${proc.className} = ${parameter.fieldName};
}
<#list proc.outputParameters as parameter>
<#if documentation>
/**
* Getter of ${parameter.name}.
*
* ${proc.fullName}
*
* @return The ${parameter.name} value.
*/
@Override
public <#if parameter.resultSet || parameter.returnResultSet>java.util.List<${parameter.javaTypeName}><#else>${parameter.javaTypeName} get${parameter.propertyName}() {
<#if parameter.date>
return ${prefixUtilityName}SafeDate.process(${parameter.fieldName}${proc.className});
<#elseif parameter.blob>
return ${prefixUtilityName}SafeByteArray.process(${parameter.fieldName}${proc.className});
<#else>
return ${parameter.fieldName}${proc.className};
}
<#if !fullConstructor>
<#if documentation>
/**
* Setter of ${parameter.name}.
*
* ${proc.fullName}
*
* @param ${parameter.fieldName} ${parameter.name} to set
*/
public void set${parameter.propertyName}(final <#if parameter.resultSet || parameter.returnResultSet>java.util.List<${parameter.javaTypeName}><#else>${parameter.javaTypeName} ${parameter.fieldName}) {
<#if parameter.date>
this.${parameter.fieldName}${proc.className} = ${prefixUtilityName}SafeDate.process(${parameter.fieldName});
<#elseif parameter.blob>
this.${parameter.fieldName}${proc.className} = ${prefixUtilityName}SafeByteArray.process(${parameter.fieldName});
<#else>
this.${parameter.fieldName}${proc.className} = ${parameter.fieldName};
}
}