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 ...
随机推荐
- pyhthon lambda
lambda x:x+1(1) >>>2 可以这样认为,lambda作为一个表达式,定义了一个匿名函数,上例的代码x为入口参数和出口参数,x+1为函数体,(1)为x的入口初始值, 用 ...
- 20155320 2016-2017-2 《Java程序设计》第五周学习总结
20155320 2016-2017-2 <Java程序设计>第五周学习总结 教材学习内容总结 错误处理 java中所有错误都会被打包为对象,可以通过try catch 代表错误的对象后做 ...
- 自适应XAML布局经验总结 (四)区域布局设计模式
本系列对实际项目中的XAML布局场景进行总结,给出了较优化的自适应布局解决方案,希望对大家有所帮助. 下面介绍区域布局设计模式. 7. 头尾模式 页面有时分为顶部栏,中间内容和底部栏三部分.这时可以使 ...
- ListView的另一种可读性更强的ViewHolder模式写法
常见的写法是这样的: @Override public View getView(int position, View convertView, ViewGroup parent) { ViewHol ...
- Net Core SignalR 测试,可以用于unity、Layair、白鹭引擎、大数据分析平台等高可用消息实时通信器。
SignalR介绍 SignalR介绍来源于微软文档,不过多解释.https://docs.microsoft.com/zh-cn/aspnet/core/signalr/introduction?v ...
- winform程序更新
更新程序和主程序是分开的,得在做一个exe可执行更新程序. 主程序在登陆时判断是否需要更新. 我这边判断方式是直接在配置文件里面设置版本号,然后和服务器上面的版本对比,低于服务器版本就更新程序. // ...
- C# 对接Https接口
最近公司项目需要对接Https接口,将对接的代码整理如下: public void Get() { HttpWebRequest request = null; request = WebReques ...
- Spring Boot项目搭建
1.Spring Boot概述 Spring Boot是由Pivotal团队提供的全新框架,其设计目的是用来简化新Spring应用的初始搭建以及开发过程.该框架使用了特定的方式来进行配置,从而使开发人 ...
- s11 day100路飞项目逻辑购物车一
Luffy项目 先看练习,如下: 一. 添加购物车和查看 1. url url(r'^shoppingcar/$', shoppingcar.ShoppingCarView.as_view({&quo ...
- scapy IPv6 NS NA报文构造
NS 报文构造: #! /bin/python from scapy.all import * a=IPv6(src='2a01:4f8:161:5300::40', dst='ff02::1:ff0 ...