templates.domain.OUTBuilder.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 documentation>
<#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 = []>
<#list proc.objectImports as parameter>
<#if objectFolderName != domainFolderName>
<#assign importList = importList + ["${javaPackage}.${objectFolderName}.${parameter.javaTypeName}"]>
<#list proc.outputParameters as parameter>
<#if parameter.date>
<#assign importList = importList + ["java.util.Date"]>
<#if fullConstructor && utilFolderName != domainFolderName>
<#assign importList = importList + ["${javaPackage}.${utilFolderName}.${prefixUtilityName}SafeDate"]>
<#elseif parameter.blob>
<#if fullConstructor && utilFolderName != domainFolderName>
<#assign importList = importList + ["${javaPackage}.${utilFolderName}.${prefixUtilityName}SafeByteArray"]>
<#elseif (parameter.resultSet || parameter.returnResultSet) && 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 builder parameters for <#if proc.function>function<#else>stored procedure.
*
* ${proc.fullName}
*
* @author @GENERATOR.NAME@
* @version @GENERATOR.VERSION@
*/
public final class ${proc.className}OUTBuilder {
<#if !fullConstructor>
<#if documentation>
/**
* Output parameter ${proc.className}OUTImpl to build.
*
* ${proc.fullName}
*/
private final ${proc.className}OUTImpl output;
<#else>
<#list proc.outputParameters as parameter>
<#if documentation>
/**
* Output parameter ${parameter.name}.
*
* ${proc.fullName}
*/
private <#if parameter.resultSet || parameter.returnResultSet>java.util.List<${parameter.javaTypeName}><#else>${parameter.javaTypeName} ${parameter.fieldName}${proc.className} = null;
<#if documentation>
/**
* Class constructor ${proc.className}OUTBuilder.
*
* ${proc.fullName}
*
*/
public ${proc.className}OUTBuilder() {
<#if !fullConstructor>
this.output = new ${proc.className}OUTImpl();
}
<#if documentation>
/**
* Class constructor ${proc.className}OUTBuilder.
*
* ${proc.fullName}
*
* @param ${proc.className}OUT out${proc.className}Instance
*
*/
public ${proc.className}OUTBuilder(final ${proc.className}OUT out${proc.className}Instance) {
<#if !fullConstructor>
this.output = new ${proc.className}OUTImpl(out${proc.className}Instance);
<#else>
<#list proc.outputParameters as parameter>
this.${parameter.fieldName}(out${proc.className}Instance.get${parameter.propertyName}());
}
<#list proc.outputParameters as parameter>
<#if documentation>
/**
* Getter of ${parameter.name}.
*
* ${proc.fullName}
*
* @return The ${proc.className}OUTBuilder out${proc.className}Instance.
*/
public ${proc.className}OUTBuilder ${parameter.fieldName}(final <#if parameter.resultSet || parameter.returnResultSet>java.util.List<${parameter.javaTypeName}><#else>${parameter.javaTypeName} ${parameter.fieldName}) {
<#if !fullConstructor>
this.output.set${parameter.propertyName}(${parameter.fieldName});
<#else>
<#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};
return this;
}
<#if documentation>
/**
* Getter ${proc.className}OUT out${proc.className}Instance.
*
* ${proc.fullName}
*
* @return The ${proc.className}OUT out${proc.className}Instance.
*/
public ${proc.className}OUT build() {
<#if fullConstructor>
return new ${proc.className}OUTImpl(${'\n'} <#list proc.outputParameters as parameter>this.${parameter.fieldName}${proc.className}<#sep>,${'\n'} ${'\n'} );
<#else>
return this.output;
}
}