Intellij IDEA 2018.1.2版本

CodeGenerator插件地址:https://github.com/lotabout/CodeGenerator/releases

步骤一:安装插件

  下载CodeGenerator.jar到本地磁盘,打开Intellij安装插件的界面进行安装

  

步骤二:添加Builder模式的模板

  

## Tutorial for writing your templates
##
## 1. First you need to know basic syntax of velocity[1].
## 2. Then it is necessary to understand the variable that CodeGenerator provides
## and its inner structure for retrieving the information you need for generating code.
## 3. Learn to use the utils provided so that you can ask for further information
## or reduce your workload.
##
## Variables Provided (Class Mode)
## -------------------------------
## Class mode means you want to create new classes(file).
##
## - ClassName: String The name spcified by `Target Class Name`
## - PackageName: String The package name specified by `Target Class Name`
## - class0: ClassEntry The class that the action is triggered upon
## - raw: PsiClass
## - String packageName
## - importList: List<String>
## - fields: List<FieldEntry>
## - allFields: List<FieldEntry>
## - methods: List<MethodEntry>
## - allMethods: List<MethodEntry>
## - innerClasses: List<ClassEntry>
## - allInnerClasses: List<ClassEntry>
## - typeParamList: List<String>
## - name: String
## - superName: String
## - superQualifiedName: String
## - qualifiedName: String
## - typeParams: int
## - hasSuper: boolean
## - deprecated: boolean
## - enum: boolean
## - exception: boolean
## - abstract: boolean
## - implementNames: String[]
## - isImplements(String): bool
## - isExtends(String): bool
## - matchName(String): bool
##
## - class1: ClassEntry The first selected class, where `1` is the postfix
## you specify in pipeline
## ...
##
## - MemberEntry (FieldEntry/MethodEntry common properties)
## - raw: PsiField(for field), PsiMethod(for method)
## - name: String
## - accessor: String
## - array: boolean
## - nestedArray: boolean
## - collection: boolean
## - map: boolean
## - primitive: boolean
## - string: boolean
## - primitiveArray: boolean
## - objectArray: boolean
## - numeric: boolean
## - object: boolean
## - date: boolean
## - set: boolean
## - list: boolean
## - stringArray: boolean
## - calendar: boolean
## - typeName: String
## - typeQualifiedName: String
## - type: String
## - boolean: boolean
## - long: boolean
## - float: boolean
## - double: boolean
## - void: boolean
## - notNull: boolean
## - char: boolean
## - byte: boolean
## - short: boolean
## - modifierStatic: boolean
## - modifierPublic: boolean
## - modifierProtected: boolean
## - modifierPackageLocal: boolean
## - modifierPrivate: boolean
## - modifierFinal: boolean
##
## - FieldEntry
## - constant: boolean
## - modifierTransient: boolean
## - modifierVolatile: boolean
## - enum: boolean
## - matchName(String): bool
##
## - MethodEntry
## - methodName: String
## - fieldName: String
## - modifierAbstract: boolean
## - modifierSynchronzied: boolean
## - modifierSynchronized: boolean
## - returnTypeVoid: boolean
## - getter: boolean
## - deprecated: boolean
## - matchName(String): bool
##
## Variables for Body Mode
## -----------------------
## - class0: ClassEntry The current class
## - fields: List<FieldEntry> All selected fields
## - methods: List<MethodEntry> All selected methods
## - members: List<MemberEntry> selected fields+methods
## - parentMethod: MethodEntry The nearest method that surround the current cursor
##
## Utilities
## ---------
## - settings: CodeStyleSettings settings of code style
## - project: Project The project instance, normally used by Psi related utilities
## - helper: GenerationHelper
## - StringUtil: Class
## - NameUtil: Class
## - PsiShortNamesCache: Class utility to search classes
## - PsiJavaPsiFacade: Class Java specific utility to search classes
## - GlobalSearchScope: Class class to create search scopes, used by above utilities
## - EntryFactory: Class EntryFactory.of(...) to turn PsiXXX to XXXEntry.
##
## Other feature
## -------------
## - Auto import. If the generated code contains full qualified name, Code Generator will try to
## import the packages automatically and shorten the name.
## For example `java.util.List<>` -> `List<>`
##
## References
## ----------
## - Velocity syntax: http://velocity.apache.org/engine/1.7/user-guide.html public static class Builder {
private ${class0.name} instance = new ${class0.name}(); private Builder() {} public static Builder getInstance() {
return new Builder();
}
public static Builder getInstance(${class0.name} instance) {
Builder builder = new Builder();
builder.instance = instance;
return builder;
}
#if ( $members.size() > 0 )
#foreach( $member in $members )
#set($name = $StringUtil.capitalizeWithJavaBeanConvention($StringUtil.sanitizeJavaIdentifier($helper.getPropertyName($member.element, $project))))
public Builder add${name}(${member.type} ${member.accessor}) {
this.instance.set${name}(${member.accessor});
return this;
}
#end
#end
public ${class0.name} build() {
return this.instance;
}
}

参考:

  【1】个人博客,http://www.littlefisher.site/2018/04/02/Eclipse%E8%BD%ACIDEA%E6%8C%87%E5%8D%97/

Intellij-插件安装-安装CodeGenerator插件并且添加Builder模板的更多相关文章

  1. IntelliJ IDEA lombok插件的安装和使用

    IntelliJ IDEA是一款非常优秀的集成开发工具,功能强大,而且插件众多.lombok是开源的代码生成库,是一款非常实用的小工具,我们在编辑实体类时可以通过lombok注解减少getter.se ...

  2. IntelliJ IDEA - 热部署插件JRebel 安装使用教程

    IntelliJ IDEA - JRebel 安装使用教程 JRebel 能做什么? JRebel 是一款热部署插件.当你的 Java-web 项目在 tomcat 中 run/debug 的时候 , ...

  3. 在IntelliJ IDEA14中安装go语言插件

    go语言的集成开发环境仍不成熟,试用了liteide,感觉很不适应,弹出菜单对程序员的干扰太大.所以就试大牌的IntelliJ IDEA,这工具本来是JAVA开发阵营的,不过它已经变为一个非常强大的支 ...

  4. 安装IntelliJ IDEA热部署tomcat插件JreBel

    最近试着使用IntelliJ IDEA这款IDE,网上说它是最好用的java开发工具~但奈何国内ecilpse市场占有率实在稳固,所以国内这个工具也就少数人在使用 当然使用起来跟ecilpse还是有很 ...

  5. Intellij idea 离线安装activiti工作流插件

    想在Intellij idea上安装一个activiti插件玩玩,由于网络环境原因,不能使用网上已有的在线搜索acti bpm并安装的方式.也在网上找了好久没找到离线安装的方式.自己摸索了一下装好了, ...

  6. 详述 IntelliJ IDEA 插件的安装及使用方法

    首先,进入插件安装界面: Mac:IntelliJ IDEA -> Preferences -> Plugins; Windows:File -> Settings -> Pl ...

  7. IntelliJ IDEA 中安装junit插件

    1.在Intellij IDEA 中安装了 Junit,TestNG插件,首先检查一下intellij IDEA 是否在安装时默认安装了这两个插件,检查方法 打开 settings -->Plu ...

  8. 十五、详述 IntelliJ IDEA 插件的安装及使用方法

    正文 首先,进入插件安装界面: Mac:IntelliJ IDEA -> Preferences -> Plugins; Windows:File -> Settings -> ...

  9. 详述IntelliJ IDEA插件的安装及使用方法(图解)

    intellij idea是一款非常优秀的软件开发工具,它拥有这强大的插件体系,可以帮助开发者完成很多重量级的功能.今天,我们来学习一下如何安装和卸载intellij idea的插件. Intelli ...

随机推荐

  1. IntelliJ IDEA 2017版 编译器使用学习笔记(三) (图文详尽版);IDE快捷键使用

    一.列操作 功能:操作多行列执行相同的功能,达到一次修改多行同类型数据的情况,如图:                 Json字符串,转为枚举类的字段: 首先进行,快捷键一行快速操作 1.选中命令,s ...

  2. scrapy windows 安装

    windows 7 系统下参照官网安装总是会提示出错,现在整理一下安装的流程 1.安装 python 2.7,添加环境变量 C:\Python27\;C:\Python27\Scripts\; 在 C ...

  3. SPSS-Friedman 秩和检验-非参数检验-K个相关样本检验 案例解析

    三人行,必有我师,是不是真有我师?三种不同类型的营销手段,最终的营销效果是否一样,随即区组秩和检验带你进入分析世界 今天跟大家讨论和分享一下:spss-Friedman 秩和检验-非参数检验-K个(多 ...

  4. SpringMVC上传图片总结(2)--- 使用百度webuploader上传组件进行上传图片

    SpringMVC上传图片总结(2)--- 使用百度webuploader上传组件进行上传图片   在上一篇文章中,我们介绍了< SpringMVC上传图片的常规上传方法 >.本文接着第一 ...

  5. 8) pom.xml

    http://maven.apache.org/ref/3.3.3/maven-model/maven.html 执行mvn命令的时候默认文件名pom.xml 也可以通过 -f 指定 比如 mvn - ...

  6. 整数重复的第n位计算公式

    513不停的重复形成513513513....,求第n位是几的计算公式.

  7. (有点递归的感觉)RGCDQ--hdu--5317

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5317 感觉好神奇呀,一堆数在一起可以找到规律,学长讲完后,觉得自己是如此的so young f[x] ...

  8. Dalvik虚拟机java方法执行流程和Method结构体分析

    Method结构体是啥? 在Dalvik虚拟机内部,每个Java方法都有一个对应的Method结构体,虚拟机根据此结构体获取方法的所有信息. Method结构体是怎样定义的? 此结构体在不同的andr ...

  9. hdu 1163 Eddy's digital Roots 【九余数定理】

    http://acm.hdu.edu.cn/showproblem.php?pid=1163 九余数定理: 如果一个数的各个数位上的数字之和能被9整除,那么这个数能被9整除:如果一个数各个数位上的数字 ...

  10. springmvc 孔浩 hibernate code

    model--User package model; import javax.persistence.Entity; import javax.persistence.GeneratedValue; ...