Intellij-插件安装-安装CodeGenerator插件并且添加Builder模板
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模板的更多相关文章
- IntelliJ IDEA lombok插件的安装和使用
IntelliJ IDEA是一款非常优秀的集成开发工具,功能强大,而且插件众多.lombok是开源的代码生成库,是一款非常实用的小工具,我们在编辑实体类时可以通过lombok注解减少getter.se ...
- IntelliJ IDEA - 热部署插件JRebel 安装使用教程
IntelliJ IDEA - JRebel 安装使用教程 JRebel 能做什么? JRebel 是一款热部署插件.当你的 Java-web 项目在 tomcat 中 run/debug 的时候 , ...
- 在IntelliJ IDEA14中安装go语言插件
go语言的集成开发环境仍不成熟,试用了liteide,感觉很不适应,弹出菜单对程序员的干扰太大.所以就试大牌的IntelliJ IDEA,这工具本来是JAVA开发阵营的,不过它已经变为一个非常强大的支 ...
- 安装IntelliJ IDEA热部署tomcat插件JreBel
最近试着使用IntelliJ IDEA这款IDE,网上说它是最好用的java开发工具~但奈何国内ecilpse市场占有率实在稳固,所以国内这个工具也就少数人在使用 当然使用起来跟ecilpse还是有很 ...
- Intellij idea 离线安装activiti工作流插件
想在Intellij idea上安装一个activiti插件玩玩,由于网络环境原因,不能使用网上已有的在线搜索acti bpm并安装的方式.也在网上找了好久没找到离线安装的方式.自己摸索了一下装好了, ...
- 详述 IntelliJ IDEA 插件的安装及使用方法
首先,进入插件安装界面: Mac:IntelliJ IDEA -> Preferences -> Plugins; Windows:File -> Settings -> Pl ...
- IntelliJ IDEA 中安装junit插件
1.在Intellij IDEA 中安装了 Junit,TestNG插件,首先检查一下intellij IDEA 是否在安装时默认安装了这两个插件,检查方法 打开 settings -->Plu ...
- 十五、详述 IntelliJ IDEA 插件的安装及使用方法
正文 首先,进入插件安装界面: Mac:IntelliJ IDEA -> Preferences -> Plugins; Windows:File -> Settings -> ...
- 详述IntelliJ IDEA插件的安装及使用方法(图解)
intellij idea是一款非常优秀的软件开发工具,它拥有这强大的插件体系,可以帮助开发者完成很多重量级的功能.今天,我们来学习一下如何安装和卸载intellij idea的插件. Intelli ...
随机推荐
- HDU 3681 Prison Break (二分 + bfs + TSP)
题意:给定上一个 n * m的矩阵,你的出发点是 F,你初始有一个电量,每走一步就会少1,如果遇到G,那么就会加满,每个G只能第一次使用,问你把所有的Y都经过,初始电量最少是多少. 析:首先先预处理每 ...
- python3中 for line1 in f1.readlines():,for line1 in f1:,循环读取一个文件夹
循环读取一个文件: fr.seek(0) fr.seek(0, 0) 概述 seek() 方法用于移动文件读取指针到指定位置. 语法 seek() 方法语法如下: fileObject.seek(of ...
- day3之装饰器
1.什么是装饰器? #在不改变原函数的调用的情况下,为原函数增加一些额外的功能,打印日志,执行时间,登录认证 2.装饰器的形成过程 # 需求写一个函数测试另一个函数的执行效率 最初的实现方式,但是改变 ...
- WCF客户端第一请求server特别慢,解决办法
最近开发WCF应用的客户端,第一连接WCF后,请求数据返回的速度特别慢,不知道原因如何.最后改了下系统生成的APP.Config文件就好了,原来没有useDefaultWebProxy的选项,没有的时 ...
- MFC自动生成代码详解(一)
首先声明这篇博客是给MFC刚刚上路的coder准备的,老鸟们就自觉无视我吧! 大家有没有感觉,创建MFC工程时他总会生成一大堆文件一大堆代码.虽然给我们带来了便利,但是调试的时候碰到这些代码总是畏首畏 ...
- date(): It is not safe to rely on the system’s timezone settings.
在执行php脚本时出现的错误: date(): It is not safe to rely on the system’s timezone settings.You are *required* ...
- Java对象的serialVersion序列化和反序列化
Java基础学习总结——Java对象的序列化和反序列化 一.序列化和反序列化的概念 把对象转换为字节序列的过程称为对象的序列化. 把字节序列恢复为对象的过程称为对象的反序列化. 对象的序列化主要有两种 ...
- Python学习-30.Python中的元组(tuple)
元组使用()定义,元组一旦定义就无法修改. 元组的索引方式同列表,也是使用[]. 元组也可以进行切片操作,使用方式同列表一样. 可以说,一个没法修改的列表就是元组. 在没有修改操作的情况下,应尽可能使 ...
- Linux应用监控工具
Linux下的监控工具丰富繁杂,如果只知道top.free之类的就太少了,而且也不能胜任日常的Linux管理工作,尤其是在排除Web服务器问题时. 本文给出5个Linux下功能更为强大的监控工具,有了 ...
- 新建/初始化git项目
Command line instructions Git global setup git config --global user.name "你的名字" git config ...