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 ...
随机推荐
- Error setting expression 'XXX‘'[Ljava.lang.with value '[Ljava.lang.String;@10101fb'
ognl报的警告,说明你的格式错误,一般是日期格式错误,格式转换器的应用,id设置的类型不对String 类型,输入了Int类型所以方法一是改变这个类中的id的属性 然后get和set也跟着改变 另一 ...
- LDA汇总
1.Blei的LDA代码(C):http://www.cs.princeton.edu/~blei/lda-c/index.html2.D.Bei的主页:http://www.cs.princeton ...
- 使用系统的CoreLocation定位
//// ViewController.m// LBS//// Created by tonnyhuang on 15/8/28.// Copyright (c) 2015年 tonnyhua ...
- C++和Python混合编程
为何人工智能(AI)首选Python?读完这篇文章你就知道了:https://blog.csdn.net/qq_41769259/article/details/79419322 C++调用Pytho ...
- codevs 1083
这道题是看了人家大牛的解题报告: 对了,要说明一下,(A+B)&1 ,表示,判断(A+B)是奇数否? 下面给出代码: #include<iostream> #include< ...
- NET平台开源项目速览(6)FluentValidation验证组件介绍与入门(转载)
原文地址:http://www.cnblogs.com/asxinyu/p/dotnet_Opensource_project_FluentValidation_1.html 阅读目录 1.基本介绍 ...
- Tomcat监听443端口的方法
当我们需要更安全的访问网站的时候就会选择使用https协议,而https协议默认的端口号为443端口,这就是我们为什么向让Tomcat监听在443端口的原因,因为监控在非80端口和443端口的web服 ...
- Win10下安装msi程序包时报2503、2502错误问题及其解决办法
Win10系统下安装TortoiseSvn.Node.js时(.msi后缀的安装文件),在点击安装时老是提示2503,2502错误,因此无法安装上. 搜索了下一般都提到是权限不够引起的该问题.但是右键 ...
- DBCC--CHECKDB--不可被替代的原因
CHECKSUM不能发现的两类问题 1. 发生在内存中的页错误,如内存损坏+第三方程序修改等 2. MS SQL Server潜在BUG导致的逻辑错误,该类错误可以使用重建索引或重建约束来修复 CHE ...
- C# 委托和接口
能用委托解决的事情,接口也都可以解决.如下所示: public static void Main() { , , , }; Util.TransformAll(values, new Squarer( ...