JetBrains Fleet 1.44 Help

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); } }

arg

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) } }

assert

Creates an assertion from a boolean expression.

public void m(boolean value) { value.assert }
public void m(boolean value) { assert value; }

cast

Surrounds an expression with a cast.

public class Foo { void m(Object o) { o.cast } }
public class Foo { void m(Object o) { (() o) } }

castvar

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; } }

else

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) { } } }

field

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; } }

for

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) { } } }

fori

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++) { } } }

format

Creates a String.format call.

public void m(String value) { value.format }
public void m(String value) { String.format(value, ); }

forr

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 &gt; 0; i--) { } } }

if

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) { } } }

inst

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; } }

instanceof

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; } }

iter

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) { } } }

lambda

Surrounds an expression with a lambda.

public void m() { foo().lambda }
public void m() { () -&gt; foo() }

new

Inserts a new call for a class.

Foo.new
new Foo()

nn

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){ } } }

not

Negates a boolean expression.

public class Foo { void m(boolean b) { m(b.not); } }
public class Foo { void m(boolean b) { m(!b); } }

notnull

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){ } } }

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){ } } }

opt

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) }

par

Parenthesizes an expression.

public class Foo { void m(Object o) { o.par } }
public class Foo { void m(Object o) { (o) } }

reqnonnull

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) } }

return

Returns a value from the containing method.

public class Foo { String m() { "result".return } }
public class Foo { String m() { return "result"; } }

serr

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); } }

souf

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); } }

sout

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); } }

soutv

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); } }

stream

Creates an Arrays.stream call.

public void m(String[] array) { array.stream }
public void m(String[] array) { Arrays.stream(array) }

switch

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) { } } }

synchronized

Produces a synchronization statement.

public class Foo { void m(Object o) { o.synchronized } }
public class Foo { void m(Object o) { synchronized (o) { } } }

test

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), ) }

testN

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), ) }

throw

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"); } }

toCompletable

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) }

toFlowable

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) }

toFlux

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) }

toMaybe

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) }

toMono

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) }

toObservable

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) }

toSingle

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) }

try

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 { }

twr

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; } }

val

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); } }

var

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; } }

varl

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); } }

while

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; } }
Last modified: 11 February 2024