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

templates.velocity.includes.macros.include.vm Maven / Gradle / Ivy

The newest version!
## set your macro here
## example:
## #macro( myFunction $a $b $c)
##  1st argument : $a, 2nd argument : $b and third one is $c
## #end
##
## call your macro with #myFunction("un","dos","three")
#macro (join $elements $do $separator)#foreach($e in $elements)#set($m_0count = $velocityCount - 1)#if ( $velocityCount > 1 )$separator#end#evaluate($do)#end#end
#####################
#macro(foreachImportedTables $m_table $do $separator $newline)
#set ( $m_count = 0 ) 
#foreach ($m_importedTable in $m_table.importedTables)
#set ( $m_importedClass = "$m_importedTable.asBeanClassNSP()" )
#set ( $m_imported_T = "$m_importedTable.asConstantVar()_T" )
#foreach( $m_fkName in $m_importedTable.getFkMapNames($m_table.name) )
#set($m_count = $m_count + 1)
#set ( $m_columnsOfFk = $m_importedTable.getForeignKeysByFkName($m_fkName) )#if($m_count > 1 )$separator#end$do#if(!$newline.empty)

#end#end#end
#end
#######################
#macro (foreachForeignTables $m_table $do $separator $newline)
#set ( $m_count = 0 )
#foreach($m_foreignTable in $m_table.foreignTables)
#set ( $m_foreignClass = "$m_foreignTable.asBeanClassNSP()" )
#set ( $m_foreign_T = "$m_foreignTable.asConstantVar()_T" )
#foreach( $m_fkName in $m_table.getFkMapNames($m_foreignTable.name) )
#set($m_count = $m_count + 1)
#set ( $m_columnsOfFk = $m_table.getForeignKeysByFkName($m_fkName) )#if($m_count > 1)$separator#end$do#if(!$newline.empty)

#end#end#end
#end
#####################
#macro(foreachAccociatedTables $m_table $do $separator)
#foreach ($m_accociatedTable in $m_table.accociatedTables)
#set ( $m_accociatedClass = "$m_accociatedTable.asBeanClassNSP()" )
#set ( $m_accociated_T = "$m_accociatedTable.asConstantVar()_T" )
#if($foreach.count > 1 )$separator#end$do#end
#end
########################
#macro(swiftThriftStruct)#if($swiftBeanSupport)@ThriftStruct
#set($final = 'final' )
#end#end
#macro(swiftThriftConstructor)#if($swiftBeanSupport)$!SPACE@ThriftConstructor
#end#end
#macro(swiftThriftField $index $requiredness $name)#if($swiftBeanSupport)$!SPACE@ThriftField(value=$index#if($name),name="$name"#end#if($requiredness),requiredness=$requiredness#end)
#end#end
#macro(swiftThriftField2 $name)#if($swiftBeanSupport)$!SPACE@ThriftField(name="$name")
#end#end
#macro(swiftThriftField3 $name)#if($swiftBeanSupport)$!SPACE@ThriftField()
#end#end
#macro(swiftThriftFieldIfVisiable $column $index $name)
#if($column.visibility.thriftVisiable)#swiftThriftField($index $null $name)#end#end
#macro(swiftThriftField2IfVisiable $column)
#if($column.visibility.thriftVisiable)#swiftThriftField2($column.varName)#end#end
#macro(jacksonField $name)#if($jacksonBeanSupport)$!SPACE@JsonProperty("$name")
#end#end
#macro(jacksonIgnore)#if($jacksonBeanSupport)$!SPACE@JsonIgnore
#end#end
#macro(jacksonFieldOrIgnore $column)
#if($column.visibility.jsonVisiable)#jacksonField($column.varName)#else#jacksonIgnore()#end#end
########################
#macro(swiftImport)
#if($swiftBeanSupport)
import com.facebook.swift.codec.ThriftStruct;
import com.facebook.swift.codec.ThriftField;
#if(!$generateForCasban)
import com.facebook.swift.codec.ThriftField.Requiredness;
#end
#end
#end
#macro(jacksonImport)
#if($jacksonBeanSupport)
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonIgnore;
#end
#end
########################
#macro(swaggerModel $description)#if($swaggerBeanSupport)@ApiModel(description=$strUtil.asJavaString($description))
#end#end
#macro(swaggerField $value $dataType $required)##
#if($swaggerBeanSupport)##
$!SPACE@ApiModelProperty(value=$strUtil.asJavaString($value)#if($dataType),dataType="$dataType"#end#if($required),required=$required#end)
#end#end
#macro(swaggerColumn $column)##
#if($swaggerBeanSupport)##
$!SPACE@ApiModelProperty(##
value = #if ( !$column.remarks.empty )$strUtil.asJavaString($column.remarks)#{else}"$column.name"#end ##
#if($column.notNull && !$column.originalDefaultValue),required=true#end ##
,dataType="$strUtil.simpleName($column.javaType)"##
)
#end##
#end
#macro(swaggerColumnHidden)##
#if($swaggerBeanSupport)$!SPACE@ApiModelProperty(hidden = true)
#end##
#end
########################
#macro(swaggerImport)
#if($swaggerBeanSupport)
import io.swagger.annotations.ApiModel;
#if(!$generateForCasban)
import io.swagger.annotations.ApiModelProperty;
#end
#end
#end
########################
#macro( converterClass $c)${c}Converter#end
########################
#macro(importLinkedTable)
#foreach ($linkedTable in $linkedTables)
import ${pkg}.${linkedTable.asBeanClass($isGeneral)};
#end
#end
####################
#macro(defineInstanceMehod $table $currentManagerClass $override)

#define($linkedManagerClass)$linkedTable.asCacheManagerClass($isGeneral)#end
#foreach ($linkedTable in $table.linkedTables)
#if($override)
    @Override
#end
    protected ${linkedTable.asManagerClass($isGeneral)} ${linkedTable.asInstanceMethod($isGeneral)}(){
#if($currentManagerClass == $table.asManagerClass($isGeneral))
        return ${linkedTable.asManagerClass($isGeneral)}.getInstance();
#else
        try{
            return ${linkedManagerClass}.getInstance();
        } catch(IllegalStateException e){
            return ${linkedTable.asManagerClass($isGeneral)}.getInstance();
        }
#end
    }
#end
#if($table.getImportedTablesAsList().contains($table))
#if($override)
    @Override
#end    
    protected $currentManagerClass ${table.asInstanceMethod($isGeneral)}(){
        return this;
    }
#end
#end
################################
#macro(codegenImport)
#if($codegenBeanSupport)
#if($table.hasMaxSize)
import com.gitee.l0km.codegen.annotations.CodegenLength;
#end
#if($table.hasNotNullNoDef)
import com.gitee.l0km.codegen.annotations.CodegenRequired;
#end
#if($table.hasCrossableDefaultvalue)
import com.gitee.l0km.codegen.annotations.CodegenDefaultvalue;
#end
#if($table.needInvalidValueAnn)
import com.gitee.l0km.codegen.annotations.CodegenInvalidValue;
#end
#if($excelBeanSupport)
import gu.sql2java.excel.annotations.*;
#end
#end###if($codegenBeanSupport)
#end###macro(codegenImport)
########################
#define($preAlloc)#if($column.preAlloc),prealloc=true#end#end
#define($codegenLength)#if($column.maxSize)@CodegenLength(max=$column.size$preAlloc)#elseif($column.fixSize)@CodegenLength(value=$column.size$preAlloc)#end#end
#define($codegenRequired)#if($column.notNull && !$column.originalDefaultValue)@CodegenRequired#end#end
#define($codegenDefaultvalue)#if($column.crossableDefaultvalue)@CodegenDefaultvalue("$column.originalDefaultValue")#end#end
#macro(codegenField $column)
#if($codegenBeanSupport)
#if($column.maxSize && $column.size > 0)
$!SPACE$codegenLength$codegenRequired$codegenDefaultvalue${column.invalidValueAnn}
#elseif($column.fixSize && $column.size > 0)
$!SPACE$codegenLength$codegenRequired$codegenDefaultvalue${column.invalidValueAnn}
#elseif($column.notNull && !$column.originalDefaultValue)
$!SPACE$codegenRequired$codegenDefaultvalue${column.invalidValueAnn}
#elseif($column.crossableDefaultvalue)
$!SPACE$codegenDefaultvalue${column.invalidValueAnn}
#elseif($column.invalidValueAnn)
$!SPACE${column.invalidValueAnn}
#end
#end###if($codegenBeanSupport)
#end###macro(codegenField $column)
## 生成字段的@ExcelColumn注解
#macro(excelField $column)
#if($excelBeanSupport)
#if($column.jsonField && !${column.namesTagMap.isEmpty()})
$!SPACE@ExcelColumns({
$!SPACE$!SPACE$!{column.excelColumn},
#foreach($entry in ${column.namesTagMap.entrySet()})
$!SPACE$!SPACE@ExcelColumn(sort=$column.ordinalPosition,columnName="$column.name.$entry.key",name="${entry.value}")#if($velocityCount < ${column.namesTagMap.size()} ),#end

#end
$!SPACE})
#else
$!SPACE$!{column.excelColumn}
#end
#end###if($excelBeanSupport)
#end###macro(excelField $column)
## 生成Java Bean的@ExcelSheet注解
#macro(excelClass $table)
#if($excelBeanSupport)
$!{table.excelSheet}
#if(!${table.namesTagMap.isEmpty()})
@ExcelColumns({
#foreach($entry in ${table.namesTagMap.entrySet()})
$!SPACE@ExcelColumn(columnName="$table.name.$entry.key",name="${entry.value}")#if($velocityCount < ${table.namesTagMap.size()} ),#end

#end###foreach($entry in ${table.namesTagMap.entrySet()})
})
#end###if(!${table.namesTagMap.isEmpty()})
#end###if($excelBeanSupport)
#end###macro(excelClass $table)
#macro(constantSupplier $associated)#if($constAnnotSupport)$!SPACE@SchemaConstantSupplier(associated="$associated")
#end#end
#macro(uncheckedIfsuperClassPackge)
#if($hasCustomSuperClass)
$!SPACE@SuppressWarnings("unchecked")
#end#end




© 2015 - 2024 Weber Informatics LLC | Privacy Policy