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

codegen.templates.include.macros.fmpp Maven / Gradle / Ivy

There is a newer version: 0.6
Show newest version
<#global varPkgName="org.unix4j.vars">
<#global varPkgPath="org/unix4j/vars">

<#function isCommandSpecificOperand def operand>
	<#return !operand.type?contains(".") && !isPrimitive(operand.type) && !isJavaLang(operand.type)> 


<#function isPrimitive type>
	<#return type=="long" || type=="int" || type=="short" || type=="byte" || type=="double" || type=="float" || type=="char" || type=="boolean">

<#function isJavaLang type>
	<#return type=="String">

<#function boxPrimitive type>
	<#if type == "int">
		<#return "Integer">
	<#elseif type == "long">
		<#return "Long">
	<#elseif type == "double">
		<#return "Double">
	<#elseif type == "float">
		<#return "Float">
	<#elseif type == "char">
		<#return "Character">
	<#elseif type == "boolean">
		<#return "Boolean">
	<#else>
		<#return type>
	

<#function isGenericType type>
	<#return type?contains("<")>

<#function normalizeVarArgType type boxPrimitives>
	<#if boxPrimitives>
		<#local normalized=boxPrimitive(type)>
	<#else>
		<#local normalized=type>
	
	<#if normalized?ends_with("...")>
		<#return normalized?substring(0, normalized?length-3)+"[]">
	<#else>
		<#return normalized>
	

<#function rawType type>
	<#if type?contains("<")>
		<#-- cut off the generic stuff -->
		<#return type?substring(0, type?index_of("<"))>
	<#else>
		<#return type>
	

<#function typeClass type prefixWithCast>
	<#local class=normalizeVarArgType(type,false)>
	<#if isGenericType(class)>
		<#local raw=rawType(class)>
		<#if prefixWithCast>
			<#return "(Class<" + class + ">)(Class)" + raw + ".class">
		<#else>
			<#return class + ".class">
		
	<#else>
		<#return class + ".class">
	


<#function countUsesStandardInput def usesStandardInput>
	<#local count=0>
	<#foreach method in def.methods>
		<#if method.usesStandardInput = usesStandardInput>
			<#local count=count+1>
		
	
	<#return count>

<#function indexOfOperandByType operands operand>
	<#foreach opd in operands?values>
		<#if opd.type == operand.type>
			<#return opd_index>
		
	
	<#return -1>

<#function setter operand>
	<#return "set" + operand.name?cap_first>

<#function isStringOperand operand>
	<#return operand.type == "String">

<#function hasStringOperand def>
	<#foreach operand in def.operands?values>
		<#if isStringOperand(operand)>
			<#return true>
		
	
	<#return false>

<#function getOptionsArgIfAny def args>
	<#foreach arg in args>
		<#if isOptionsArg(def, arg)>
			<#return arg>
		
	
	<#return "">

<#function hasOptionsArg def args>
	<#return getOptionsArgIfAny(def, args)?length != 0>

<#function isOptionsArg def arg>
	<#return def.operands[arg].type == optionsName>

<#function hasArgsOperand def>
	<#foreach operand in def.operands?values>
		<#if isArgsOperand(operand)>
			<#return true>
		
	
	<#return false>

<#function isArgsOperandName operandName>
	<#return operandName == "args">

<#function isArgsOperand operand>
	<#return isArgsOperandName(operand.name)>





© 2015 - 2024 Weber Informatics LLC | Privacy Policy