List of Java postfix completion templates
This table summarizes the postfix completion templates that you can use with your Java code.
Name | Description | Example. Before | Example. After |
---|---|---|---|
| Negates a boolean expression. |
public class Foo {
void m(boolean b) {
m(b!);
}
}
|
public class Foo {
void m(boolean b) {
m(!b);
}
}
|
| Wraps an object with a function call. |
public class Foo {
void m(Object o) {
o.arg
}
}
|
public class Foo {
void m(Object o) {
call(o)
}
}
|
| Creates an assertion from a boolean expression. |
public void m(boolean value) {
value.assert
}
|
public void m(boolean value) {
assert value;
}
|
| Surrounds an expression with a cast. |
public class Foo {
void m(Object o) {
o.cast
}
}
|
public class Foo {
void m(Object o) {
(() o)
}
}
|
| Creates a new variable for the expression with type casting. |
void m(Object o) {
if (o instanceof String) {
o.castvar
}
}
|
void m(Object o) {
if (o instanceof String) {
String o = (String)o;
}
}
|
| Adds a check verifying that a boolean expression is false. |
public class Foo {
void m(boolean b) {
b.else
}
}
|
public class Foo {
void m(boolean b) {
if (!b) {
}
}
}
|
| Introduces a field for an expression. |
public class Foo {
public Foo(int arg) {
arg.field
}
}
|
public class Foo {
private int foo;
public Foo(int arg) {
foo = arg;
}
}
|
| Iterates over an enumerable collection. |
public class Foo {
void m() {
int[] values = {1, 2, 3};
values.for
}
}
|
public class Foo {
void m() {
int[] values = {1, 2, 3};
for (int value : values) {
}
}
}
|
| Iterates with an index over a collection. |
public class Foo {
void m() {
int foo = 100;
foo.fori
}
}
|
public class Foo {
void m() {
int foo = 100;
for (int i = 0; i < foo; i++) {
}
}
}
|
| Creates a String.format call. |
public void m(String value) {
value.format
}
|
public void m(String value) {
String.format(value, );
}
|
| Iterates with an index in reverse order. The template can also be used on an array or a list to iterate over its elements in reverse order. |
public class Foo {
void m() {
int foo = 100;
foo.forr
}
}
|
public class Foo {
void m() {
int foo = 100;
for (int i = foo; i > 0; i--) {
}
}
}
|
| Adds a check verifying that a boolean expression is true. |
public class Foo {
void m(boolean b) {
b.if
}
}
|
public class Foo {
void m(boolean b) {
if (b) {
}
}
}
|
| Surrounds an expression with instanceof. |
public class Foo {
void m(Object o) {
o.inst
}
}
|
public class Foo {
void m(Object o) {
o instanceof ? (() o) : null;
}
}
|
| Surrounds an expression with instanceof. |
public class Foo {
void m(Object o) {
o.instanceof
}
}
|
public class Foo {
void m(Object o) {
o instanceof ? (() o) : null;
}
}
|
| Iterates over an enumerable collection. |
public class Foo {
void m() {
int[] values = {1, 2, 3};
values.iter
}
}
|
public class Foo {
void m() {
int[] values = {1, 2, 3};
for (int value : values) {
}
}
}
|
| Surrounds an expression with a lambda. |
public void m() {
foo().lambda
}
|
public void m() {
() -> foo()
}
|
| Inserts a new call for a class. |
Foo.new
|
new Foo()
|
| Adds a check verifying that an expression is not null. |
public class Foo {
void m(Object o) {
o.nn
}
}
|
public class Foo {
void m(Object o) {
if (o != null){
}
}
}
|
| Negates a boolean expression. |
public class Foo {
void m(boolean b) {
m(b.not);
}
}
|
public class Foo {
void m(boolean b) {
m(!b);
}
}
|
| Adds a check verifying that an expression is not null. |
public class Foo {
void m(Object o) {
o.notnull
}
}
|
public class Foo {
void m(Object o) {
if (o != null){
}
}
}
|
| Adds a check verifying that an expression is null. |
public class Foo {
void m(Object o) {
o.null
}
}
|
public class Foo {
void m(Object o) {
if (o == null){
}
}
}
|
| Creates an Optional object. |
public void m(int intValue, double doubleValue, long longValue, Object objValue) {
intValue.opt
doubleValue.opt
longValue.opt
objValue.opt
}
|
public void m(int intValue, double doubleValue, long longValue, Object objValue) {
OptionalInt.of(intValue)
OptionalDouble.of(doubleValue)
OptionalLong.of(longValue)
Optional.ofNullable(objValue)
}
|
| Parenthesizes an expression. |
public class Foo {
void m(Object o) {
o.par
}
}
|
public class Foo {
void m(Object o) {
(o)
}
}
|
| Wraps an object with Objects.requireNonNull. |
public class Foo {
void m(Object o) {
o.reqnonnull
}
}
|
public class Foo {
void m(Object o) {
Objects.requireNonNull(o)
}
}
|
| Returns a value from the containing method. |
public class Foo {
String m() {
"result".return
}
}
|
public class Foo {
String m() {
return "result";
}
}
|
| Creates a System.err.println call. |
public class Foo {
void m(boolean b) {
b.serr
}
}
|
public class Foo {
void m(boolean b) {
System.err.println(b);
}
}
|
| Creates a System.out.printf call. |
public class Foo {
void m(boolean b) {
b.souf
}
}
|
public class Foo {
void m(boolean b) {
System.out.printf("", b);
}
}
|
| Creates a System.out.println call. |
public class Foo {
void m(boolean b) {
b.sout
}
}
|
public class Foo {
void m(boolean b) {
System.out.println(b);
}
}
|
| Creates System.out.println with a description of the printed value call. |
public class Foo {
void m(boolean b) {
b.soutv
}
}
|
public class Foo {
void m(boolean b) {
System.out.println("b = " + b);
}
}
|
| Creates an Arrays.stream call. |
public void m(String[] array) {
array.stream
}
|
public void m(String[] array) {
Arrays.stream(array)
}
|
| Produces switch over integral/enum/string values. |
public enum Foo {
A, B, C;
void f(Foo foo) {
foo.switch
}
}
|
public enum Foo {
A, B, C;
void f(Foo foo) {
switch (foo) {
}
}
}
|
| Produces a synchronization statement. |
public class Foo {
void m(Object o) {
o.synchronized
}
}
|
public class Foo {
void m(Object o) {
synchronized (o) {
}
}
}
|
| Wraps Flux/Mono with reactor.test.StepVerifier.create method call. |
public void m() {
Flux.just(1).test
Flux.just(2).testN
}
|
public void m() {
StepVerifier.create(Flux.just(1))
StepVerifier.create(Flux.just(2), )
}
|
| Wraps Flux/Mono with reactor.test.StepVerifier.create method call. |
public void m() {
Flux.just(1).test
Flux.just(2).testN
}
|
public void m() {
StepVerifier.create(Flux.just(1))
StepVerifier.create(Flux.just(2), )
}
|
| Throws an expression of the Throwable type. |
public class Foo {
void m() {
new RuntimeException("error").throw
}
}
|
public class Foo {
void m() {
throw new RuntimeException("error");
}
}
|
| Wraps expression with a suitable RxJava2 or RxJava3 Completable factory. |
public void m(Throwable error,
String s,
Future<Integer> future,
Callable<String> callable,
Single<String> single) {
error.toCompletable
s.toCompletable
future.toCompletable
callable.toCompletable
single.toCompletable
}
|
public void m(Throwable error,
String s,
Future<Integer> future,
Callable<String> callable,
Single<String> single) {
Completable.error(error)
Completable.complete()
Completable.fromFuture(future)
Completable.fromCallable(callable)
Completable.fromSingle(single)
}
|
| Wraps expression with a suitable RxJava2 or RxJava3 Flowable factory. |
public void m(Throwable error,
String s,
List<Integer> list,
String[] array,
Publisher<Integer> p,
Stream<Integer> stream) {
error.toFlowable
s.toFlowable
list.toFlowable
array.toFlowable
p.toFlowable
stream.toFlowable
}
|
public void m(Throwable error,
String s,
List<Integer> list,
String[] array,
Publisher<Integer> p,
Stream<Integer> stream) {
Flowable.error(error)
Flowable.just(s)
Flowable.fromIterable(list)
Flowable.fromArray(array)
Flowable.fromPublisher(p)
Flowable.fromStream(stream)
}
|
| Wraps expression with a suitable reactor.core.publisher.Flux factory. |
public void m(Throwable error,
String s,
List<Integer> list,
String[] array,
Mono<Integer> mono,
Stream<Integer> stream) {
error.toFlux
s.toFlux
list.toFlux
array.toFlux
mono.toFlux
stream.toFlux
}
|
public void m(Throwable error,
String s,
List<Integer> list,
String[] array,
Mono<Integer> mono,
Stream<Integer> stream) {
Flux.error(error)
Flux.just(s)
Flux.fromIterable(list)
Flux.fromArray(array)
Flux.from(mono)
Flux.fromStream(stream)
}
|
| Wraps expression with a suitable RxJava2 or RxJava3 Maybe factory. |
public void m(Throwable error,
String s,
Future<Integer> future,
Callable<String> callable,
Single<String> single) {
error.toMaybe
s.toMaybe
future.toMaybe
callable.toMaybe
single.toMaybe
}
|
public void m(Throwable error,
String s,
Future<Integer> future,
Callable<String> callable,
Single<String> single) {
Maybe.error(error)
Maybe.just(s)
Maybe.fromFuture(future)
Maybe.fromCallable(callable)
Maybe.fromSingle(single)
}
|
| Wraps expression with a suitable reactor.core.publisher.Mono factory. |
public void m(Throwable error,
String s,
CompletableFuture<Integer> future,
Callable<String> callable,
Mono<Integer> mono,
Supplier<Double> sup) {
error.toMono
s.toMono
future.toMono
callable.toMono
mono.toMono
sup.toMono
}
|
public void m(Throwable error,
String s,
CompletableFuture<Integer> future,
Callable<String> callable,
Mono<Integer> mono,
Supplier<Double> sup) {
Mono.error(error)
Mono.just(s)
Mono.fromFuture(future)
Mono.fromCallable(callable)
Mono.from(mono)
Mono.fromSupplier(sup)
}
|
| Wraps expression with a suitable RxJava2 or RxJava3 Observable factory. |
public void m(Throwable error,
String s,
List<Integer> list,
String[] array,
Publisher<Integer> p,
Stream<Integer> stream) {
error.toObservable
s.toObservable
list.toObservable
array.toObservable
p.toObservable
stream.toObservable
}
|
public void m(Throwable error,
String s,
List<Integer> list,
String[] array,
Publisher<Integer> p,
Stream<Integer> stream) {
Observable.error(error)
Observable.just(s)
Observable.fromIterable(list)
Observable.fromArray(array)
Observable.fromPublisher(p)
Observable.fromStream(stream)
}
|
| Wraps expression with a suitable RxJava2 or RxJava3 Single factory. |
public void m(Throwable error,
String s,
Future<Integer> future,
Callable<String> callable,
Maybe<String> maybe) {
error.toSingle
s.toSingle
future.toSingle
callable.toSingle
maybe.toSingle
}
|
public void m(Throwable error,
String s,
Future<Integer> future,
Callable<String> callable,
Maybe<String> maybe) {
Single.error(error)
Single.just(s)
Single.fromFuture(future)
Single.fromCallable(callable)
Single.fromMaybe(maybe)
}
|
| Inserts a statement in a try-catch block. |
public void m2() {
m().try
}
public void m() throws CheckedException { }
|
public void m2() {
try {
m();
} catch(CheckedException e) {
e.printStackTrace();
}
}
public void m() throws CheckedException { }
|
| Inserts a statement in a try-with-resources block (Java 7 or higher is required). |
public class Foo {
void m() {
getStream().twr
}
AutoCloseable getStream()
{
return null;
}
}
|
public class Foo {
void m() {
try (AutoCloseable stream = getStream()) {
} catch (Exception e) {
}
}
AutoCloseable getStream()
{
return null;
}
}
|
| Introduces a lombok.val variable for an expression. |
public class Foo {
void m(Object o) {
String.valueOf(123).val
}
}
|
public class Foo {
void m(Object o) {
lombok.val foo = String.valueOf(123);
}
}
|
| Introduces a variable for an expression. |
public class Foo {
void m(Object o) {
o instanceof String.var
}
}
|
public class Foo {
void m(Object o) {
boolean foo = o instanceof String;
}
}
|
| Introduces a lombok.var variable for an expression. |
public class Foo {
void m(Object o) {
String.valueOf(123).varl
}
}
|
public class Foo {
void m(Object o) {
lombok.var foo = String.valueOf(123);
}
}
|
| Iterates while the boolean statement is true. |
public class Foo {
void m(boolean x) {
x.while
return;
}
}
|
public class Foo {
void m(boolean x) {
while (x) {
}
return;
}
}
|