All Downloads are FREE. Search and download functionalities are using the official Maven repository.

crud_nested_java_server_app.functions.ftl Maven / Gradle / Ivy

There is a newer version: 2.4.3
Show newest version
<#-- -------------------- -->
<#-- OASP SPECIFIC MACROS -->
<#-- -------------------- -->

<#--
	Generates all field declaration whereas Entity references will be converted to appropriate id references
-->
<#macro generateFieldDeclarations_withRespectTo_entityObjectToIdReferenceConversion isSearchCriteria=false>
<#list pojo.fields as field>
<#if field.type?contains("Entity")> <#-- add ID getter & setter for Entity references only for ID references -->
  <#if !field.type?starts_with("List<") && !field.type?starts_with("Set<")> <#-- do not generate field for multiple relation -->
   	 private ${field.type?replace("[^<>,]+Entity","Long","r")} ${OaspUtil.resolveIdVariableName(classObject,field)};
  
<#elseif field.type?contains("Embeddable")>
	<#if isSearchCriteria>
		private ${field.type?replace("Embeddable","SearchCriteriaTo")} ${field.name};
	<#else>
		private ${field.type?replace("Embeddable","Eto")} ${field.name};
	
<#elseif isSearchCriteria && JavaUtil.equalsJavaPrimitive(classObject,field.name)>
  private ${JavaUtil.boxJavaPrimitives(classObject,field.name)} ${field.name};
<#else>
	private ${field.type} ${field.name};




<#--
	Generates all setter and getter for the fields whereas for Entity fields it will generate setter and getter for id references
-->
<#macro generateSetterAndGetter_withRespectTo_entityObjectToIdReferenceConversion implementsInterface=true, isInterface=false, isSearchCriteria=false>
<#list pojo.fields as field>
<#if field.type?contains("Entity")> <#-- add ID getter & setter for Entity references only for ID references -->
   <#if !field.type?starts_with("List<") && !field.type?starts_with("Set<")> <#-- do not generate getters & setters for multiple relation -->
    	<#assign idVar = OaspUtil.resolveIdVariableName(classObject,field)>
    	<#if implementsInterface>@Override
    	public ${OaspUtil.getSimpleEntityTypeAsLongReference(field)} ${OaspUtil.resolveIdGetter(classObject,field)} <#if isInterface>;<#else>{
    		return ${idVar};
    	}
    
    	<#if implementsInterface>@Override
    	public void ${OaspUtil.resolveIdSetter(classObject,field)}(${OaspUtil.getSimpleEntityTypeAsLongReference(field)} ${idVar}) <#if isInterface>;<#else>{
    		this.${idVar} = ${idVar};
    	}
   
<#elseif field.type?contains("Embeddable")>
	<#if isSearchCriteria>
		public ${field.type?replace("Embeddable","SearchCriteriaTo")} <#if field.type=='boolean'>is<#else>get${field.name?cap_first}() <#if isInterface>;<#else>{
			return ${field.name};
		}

		public void set${field.name?cap_first}(${field.type?replace("Embeddable","SearchCriteriaTo")} ${field.name}) <#if isInterface>;<#else>{
			this.${field.name} = ${field.name};
		}
	<#else>
		public ${field.type?replace("Embeddable","")} <#if field.type=='boolean'>is<#else>get${field.name?cap_first}() <#if isInterface>;<#else>{
			return ${field.name};
		}

		public void set${field.name?cap_first}(${field.type?replace("Embeddable","")} ${field.name}) <#if isInterface>;<#else>{
			this.${field.name} = ${field.name};
		}
	
<#else>
  <#if implementsInterface>@Override
	public <#if isSearchCriteria>${JavaUtil.boxJavaPrimitives(classObject,field.name)}<#else>${field.type} <#if field.type=='boolean'>is<#else>get${field.name?cap_first}() <#if isInterface>;<#else>{
		return ${field.name};
	}

	<#if implementsInterface>@Override
	public void set${field.name?cap_first}(<#if isSearchCriteria>${JavaUtil.boxJavaPrimitives(classObject,field.name)}<#else>${field.type} ${field.name}) <#if isInterface>;<#else>{
		this.${field.name} = ${field.name};
	}






© 2015 - 2024 Weber Informatics LLC | Privacy Policy