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. 学习前端的菜鸡对JS 的classList理解

    classList 在早期的时候要添加,删除类 需要用className去获取,然后通过正则表达式去判断这个类是否存在. 代码上去会有点麻烦,现在有了classList 就方便了很多. ——————— ...

  2. BSD Socket 通信

    Berkeley sockets is an application programming interface (API) for Internet sockets and Unix domain ...

  3. (最小生成树)Constructing Roads -- poj -- 2421

    链接: http://poj.org/problem?id=2421 Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 2113 ...

  4. Java web 调试技巧之查看浏览器中调试中的network

    在java web开发过程中尤其后台开发经常需要查看浏览器调试中的network项:今天在开发在线预览系统时用到了flexpaper插件,这个插件会调用FlexPaperViewer.swf这个软件( ...

  5. TFS 如何強制撤銷被簽出的文件

    我们在使用TFS (Team Foundation Server) 源代码管理的时候,源代码管理会在每个PC上创建一个工作区,然后这个工作区域映像到服务器上的源码文件夹,我们在正常签入,签出的时候,我 ...

  6. AbpZero之企业微信---登录(拓展第三方auth授权登录)---第一步:查看AbpZero的auth第三方登录的底层机制

    在AbpZero框架中,auth登录接口位于Web.Core库下的Controllers文件夹的TokenAuthController.cs的ExternalAuthenticate方法 Extern ...

  7. 设置oracle主键自增长

    创建test表后,创建序列: CREATE sequence seq_test INCREMENT BY 1 START WITH 1 minvalue 1   成功后,插入一条语句进行测试:   I ...

  8. SL 的 DATAGRID中如何加入计算列?

    例如,我的数据库中实体表对应到EF中的实体类是 class { public int  F1; public int F2; } 我在服务端做domainservice 我在SL端使用wcf ria, ...

  9. 基于Spring MVC的web应用随应用启动而加载

    写个类实现org.springframework.context.ApplicationContextAware接口即可. 但是如下的程序会在启动时加载两次: @Controller public c ...

  10. Delphi - 10.1编译OSX10.12程序遇到错误解决了!

    昨天,尝试Delphi的跨平台开发功能,在windows10下,做了一个控制台程序,发布目标平台是OSX10.12,中间配置过程都非常顺利,没有任何错误,但是当编译运行时候出现下面错误: [dccos ...