IntelliJ IDEA的Postfix Completion功能列表
关于Postfix Compoletion功能笔者不在赘述,有兴趣可以去搜索了解下,本文只列出编写Java代码的一些IDEA提供的Postfix Completion功能和自定义的Postfix Completion,方便查询和记忆。
自带Postfix Completion
快捷方式 | before | after |
---|
! | b! | !b |
.arg | o.arg | $输入方法名$(o) |
.assert | v.assert | assert v |
.cast | o.cast | (($输入类型$) o) |
.castvar | o.castvar | T t=($输入类型$) o |
.else | o.else | if(!b){} |
.filed | o.field | 生成field |
.for | coll.for | 增强for循环 |
.fori | n.fori | for循环,n作为上边界 |
.format | v.format | String.format(value, $输入格式$); |
.forr | n.forr | 类似.fori,但是n作为上边界,i–的 |
.if | n.if | if(n){},生成if语句 |
.inst | o.inst | o instanceof $输入类型$ ? (($输入类型$) o) : null; |
.instanceof | oinstanceof | 同上 |
.iter | list.iter | 同for |
.lambda | foo().lambda | ()->foo() |
.new | Foo.new | new Foo() |
.nn | o.nn | if(o!=null){} |
.not | o.not | 同! |
.notnull | o.notnull | 同nn |
.null | o.null | if(o==null){} |
.opt | o.opt | Optional.ofNullable(o) |
.par | o.par | (o) |
.reqnonnull | o.reqnonnull | Objects.requireNonNull(o) |
.return | o.return | return o; |
.serr | o.serr | System.err.println(b); |
.souf | o.soutf | System.out.printf("", b); |
.sout | o.sout | System.out.println(b); |
.soutv | o.soutv | System.out.println("b = " + b); |
.stream | array.stream | Arrays.stream(array) |
.switch | o.switch | switch (foo) {} |
.synchronized | o.synchronized | synchronized(o){} |
.test | Flux.just(1).test | StepVerifier.create(Flux.just(1))//响应式编程适用 |
.testN | Flux.just(1).testN | StepVerifier.create(Flux.just(2), )//响应式编程适用 |
.throw | e.throw | throw e; |
.toFlux | list.toFlux | Flux.fromIterable(list)//响应式编程适用 |
.toMono | e.toMono | Mono.error(error)//响应式编程适用 |
.try | m().try | try {m();} catch(CheckedException e) {e.printStackTrace();} |
.twr | closable.twr | try (AutoCloseable stream = getStream()) {} catch (Exception e) {}// 也就是Java7的try with resources |
.val | String.valueOf(123).val | lombok.val foo = String.valueOf(123);// lombok的api |
.var | exp.var | T foo=exp; |
.varl | String.valueOf(123).varl | lombok.var foo = String.valueOf(123); |
.while | x.while | while(x){} |
自定义Postfix Completion
快捷方式 | before | after |
---|
.snb | s.snb | if(StringUtils.isNotBlank(s)){} |
.sne | s.sne | if(StringUtils.isNotEmpty(s)){} |
.cne | coll.cne | if(CollectionUtils.isNotEmpty(coll)){} |
.mne | map.mne | if(MapUtils.isNotEmpty(map)){} |
.copy | bean.copy | BeanUtil.copyProperties(bean,$输入类型$); |
.copyen | bean.copyen | BeanUtil.copyProperties(bean, $输入类型$, CopyOptions.create().setIgnoreNullValue(true)); |