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 ...
随机推荐
- UVa 111 History Grading (简单DP,LIS或LCS)
题意:题意就是坑,看不大懂么,结果就做不对,如果看懂了就so easy了,给定n个事件,注意的是, 它给的是第i个事件发生在第多少位,并不是像我们想的,第i位是哪个事件,举个例子吧,4 2 3 1, ...
- b4和tncl_extract_UNCL_new
# -*- coding:utf-8 -*- import re ''' 适应新版本 注意: 1)17A文件改完后缀后,需要转为UTF-8无BOM格式,才能正确处理. 2)fr = open(file ...
- python编码(三)
python 有str object 和 unicode object 两种字符串,都可以存放字符的字节编码,但是他们是不同的type,这一点很重要,也是为什么会有encode(编码)和decode( ...
- Freetype字体引擎分析与指南
Freetype字体引擎分析与指南,很不错的一篇教程,推荐!!
- MFC 的SetWindowPos 用法
转自于:http://hi.baidu.com/max_new/blog/item/e2bbe607b1f127c57b8947c0.html 许多软件,特别是占桌面面积不是很大的软件,通常都提供了一 ...
- Mysql工作記錄之修改默認存儲引擎及重設root用戶密碼
1>修改默認存儲引擎方法 修改配置文件,然後重啟mysql服務: [root@CHW mysql]# cat /etc/my.cnf [my ...
- Python学习-15.Python的中的套接字socket
Python应用最广泛的要数web方面了.因此,socket显得十分重要. 要使用socket,必须引入socket模块,因此在Python脚本开头先写入 import socket 学过socket ...
- winform之combobox
绑定键值对: ArrayList mylist = new ArrayList(); mylist.Add(new DictionaryEntry("WinFormURL", &q ...
- IIS 绑定 HTTPS 域名
HTTPS为SSL安全通道,虽然并不清楚具体有什么用,但至少网站看上去比HTTP上档次,访问速度也没什么影响,所以有条件的话,还是做下,可以做噱头忽悠人. WIN2008系统 因为端口443冲突,只能 ...
- 20164317《网络对抗技术》Exp2 后门原理与实践
1.实验内容 (1)使用netcat获取主机操作Shell,cron启动 (2)使用socat获取主机操作Shell, 任务计划启动 (3)使用MSF meterpreter(或其他软件)生成可执行文 ...