http://www.jindent.com |
|
Next: Method Calls |
Maximal gap size of indentations for multiple variable and field declarations |
public class MyConstants | { | public static final String constantOne = "Some text here ...", | |-----------------------------|constantTwo = "Some other text...", | constantThree = getTextFromMethod( | parameterA, paramterB), | constantFour = "bla bla ..."; | } | |
public class MyConstants | { | public static final String constantOne = "Some text here ...", | |--- relative gap size ---|constantTwo = "Some other text...", constantThree = getTextFromMethod( | parameterA, paramterB), | constantFour = "bla bla ..."; | } | |
public class MyConstants | { | public static final String constantOne = "Some text here ...", | |----- absolute gap size -----|constantTwo = "Some other text...", constantThree = getTextFromMethod( | parameterA, paramterB), | constantFour = "bla bla ..."; | } | |
public class MyConstants | { | public static final String constantOne = "Some text here ...", | |--- relative gap size: 31 ---|constantTwo = "Some other text...", constantThree = getTextFromMethod( | parameterA, paramterB), | constantFour = "bla bla ..."; | } | |
public class MyConstants | { | public static final String | |--|constantOne = "Some text here ...", | constantTwo = "Some other text...", | constantThree = getTextFromMethod(parameterA, paramterB), | constantFour = "bla bla ..."; | } | |
infinite
to leave gaps untouched.See also: | Maximal gap size of indentations , Align assignments |
Wrap initializers of variable and field declarations to right side (in this case the 'maximal gap settings' will be ignored) |
LongClassName tmp; | String stringValue1 = "some text here ..."; | String stringValue2 = getTextFromMethod( | parameter1, parameter2); | |
LongClassName tmp; | String stringValue1 = "some text here ..."; | String stringValue2 = getTextFromMethod( | parameter1, parameter2); | |
Wrap before extends |
extends
.always
and indent by 4 white spaces:
public class MyClass extends AnotherClass { ... } |
extends
to a new line
even if it would fit into the specified maximal line length.extends
is indented by setting: "Indentation of wrapped extends"never
:
public class MyClass extends AnotherClass { ... } |
extends
to a new line
even if it does not fit into the specified maximal line length.on demand
and indent by 0 white spaces:
public class MyClass | extends AnotherClass { | ... | } | |
extends
on demand:extends
fits into the specified maximal line length then the token won't be wrapped.
If it exceeds maximal line length it will be wrapped to a new line though. The wrapped token
will be indented by setting: "Indentation of wrapped extends"if line exceeds
works a bit different:extends
belongs to exceeds maximal line length then
extends
will be wrapped.
public class MyClass extends AnotherClass implements MyInterface { ... | } | |
extends
does not exceed the specified maximal line length,
but another token MyInterface
does. We consider this case as 'the line exceeds
maximal line length' and therefore token extends
will be wrapped and
indented by setting: "Indentation of wrapped extends"
public class MyClass | extends AnotherClass implements MyInterface { | ... | } | |
See also: | Indentation of wrapped extends |
Indentation of wrapped extends |
extends
by a specified number of white spaces.See also: | Wrap before extends |
Wrap extended classes |
always
:
public interface MyInterfaces extends InterfaceOne, InterfaceTwo, InterfaceThree { ... } |
never
:
public interface MyInterfaces extends InterfaceOne, InterfaceTwo, InterfaceThree { ... } |
on demand
:
public interface MyInterfaces extends InterfaceOne, InterfaceTwo, | InterfaceThree { | ... | } | |
if line exceeds
works a bit different:
public interface MyInterfaces extends InterfaceOne, InterfaceTwo, InterfaceThree { ... | } | |
InterfaceThree
exceeds the specified maximal line length,
therefore we consider this case as 'the line exceeds maximal line length'
and all extended class/interface names will be wrapped:
public interface MyInterfaces extends InterfaceOne, | InterfaceTwo, | InterfaceThree { | ... | } | |
Wrap before implements |
implements
.always
and indent by 4 white spaces:
public class MyClass implements MyInterface { ... } |
implements
to a new line
even if it would fit into the specified maximal line length.implements
is indented by setting: "Indentation of wrapped implements"
never
:
public class MyClass implements MyInterface { ... } |
implements
to a new line
even if it does not fit into the specified maximal line length.on demand
and indent by 0 white spaces:
public class MyClass | implements MyInterface { | ... | } | |
implements
on demand:implements
fits into the specified maximal line length then the token won't be wrapped.
If it exceeds maximal line length it will be wrapped to a new line though. The wrapped token
will be indented by setting: "Indentation of wrapped implements"if line exceeds
works a bit different:implements
belongs to exceeds maximal line length then
implements
will be wrapped.
public class MyClass implements InteraceOne, InterfaceTwo, InterfaceThree { ... | } | |
implements
does not exceed the specified maximal line length,
but another token InterfaceThree
does. We consider this case as 'the line exceeds
maximal line length' and therefore token implements
will be wrapped and
indented by setting: "Indentation of wrapped implements"
public class MyClass | implements InteraceOne, InterfaceTwo, InterfaceThree { | ... | } | |
See also: | Indentation of wrapped implements |
Indentation of wrapped implements |
implements
by a specified number of white spaces.See also: | Wrap before implements |
Wrap implemented interfaces |
always
:
public class MyClass implements InterfaceOne, InterfaceTwo, InterfaceThree { ... } |
never
:
public class MyClass implements InterfaceOne, InterfaceTwo, InterfaceThree { ... } |
on demand
:
public class MyClass implements InterfaceOne, InterfaceTwo, | InterfaceThree { | ... | } | |
if line exceeds
works a bit different:
public class MyClass implements InterfaceOne, InterfaceTwo, InterfaceThree { ... | } | |
InterfaceThree
exceeds the specified maximal line length,
therefore we consider this case as 'the line exceeds maximal line length'
and all implemented interface names will be wrapped:
public class MyClass implements InterfaceOne, | InterfaceTwo, | InterfaceThree { | ... | } | |
Wrap after modifiers |
always
:
public void method() { ... } |
never
:
public void method() { ... } |
on demand
:
public static | void aPrettyLongMethodNameWhichCannotBeWrapped() | { | ... | } | |
if line exceeds
works a bit different:
public static void longMethodName(int paramaterOne, int parameterTwo) | { | ... | } | |
parameterTwo
exceeds the specified maximal line length,
therefore we consider this case as 'the line exceeds maximal line length'
and it will be wrapped after modifiers:
public static | void longMethodName(int paramaterOne, int parameterTwo) | { | ... | } | |
Wrap after method declaration return types |
always
:
public float method() { ... } |
never
:
public float method() { ... } |
on demand
:
public static float | aPrettyLongMethodNameWhichCannotBeWrapped() | { | ... | } | |
if line exceeds
works a bit different:
public static int longMethodName(int paramaterOne, int parameterTwo) { | ... | } | |
parameterTwo
exceeds the specified maximal line length,
therefore we consider this case as 'the line exceeds maximal line length'
and it will be wrapped after its return type:
public static int | longMethodName(int paramaterOne, int parameterTwo) | { | ... | } | |
Wrap before left parentheses ( |
always
:
public void method (int parameterOne, int parameterTwo) { ... } |
never
:
public void method(int parameterOne, int parameterTwo) { ... } |
on demand
:
public static void aPrettyLongMethodName (int parameterOne) | { | ... | } | |
if line exceeds
works a bit different:
public static int longMethodName(int paramaterOne, int parameterTwo) { | ... | } | |
parameterTwo
exceeds the specified maximal line length,
therefore we consider this case as 'the line exceeds maximal line length'
and it will be wrapped after its left parenthesis:
public static int longMethodName | (int paramaterOne, int parameterTwo) | { | ... | } | |
See also: | Indentation of wrapped left parentheses ( |
Indentation of wrapped left parentheses ( |
See also: | Wrap before left parentheses ( |
Wrap first parameter |
always
:
public void method( int parameterOne, int parameterTwo) { ... } |
never
:
public void method(int parameterOne, int parameterTwo) { ... } |
on demand
:
public static void aPrettyLongMethodName( | int parameterOne) | { | ... | } | |
if line exceeds
works a bit different:
public static int longMethodName(int paramaterOne, int parameterTwo) { | ... | } | |
parameterTwo
exceeds the specified maximal line length,
therefore we consider this case as 'the line exceeds maximal line length'
and first parameter will be wrapped:
public static int longMethodName( | int paramaterOne, int parameterTwo) | { | ... | } | |
Indentation of first wrapped parameter |
See also: | Wrap first parameter |
Wrap all other parameters |
always
:
public void method(int parameterOne, int parameterTwo, int parameterThree) { ... } |
never
:
public void method(int parameterOne, int parameterTwo, int parameterThree) { ... } |
on demand
:
public void method(int parameterOne, int parameterTwo, | int parameterThree) | { | ... | } | |
if line exceeds
works a bit different:
public void method(int parameterOne, int parameterTwo, int parameterThree) { | ... | } | |
parameterThree
exceeds the specified maximal line length,
therefore we consider this case as 'the line exceeds maximal line length' and all
parameters will be wrapped:
public void method(int parameterOne, | int parameterTwo, | int parameterThree) | { | ... | } | |
Wrap before right parentheses ) |
always
:
public void method(int parameterOne, int parameterTwo ) { ... } |
never
:
public void method(int parameterOne, int parameterTwo) { ... } |
on demand
:
public static void aPrettyLongMethodName(int parameterOne, int parameterTwo ) | { | ... | } | |
if line exceeds
works a bit different:
public static int longMethodName(int paramaterOne, int parameterTwo) { | ... | } | |
parameterTwo
exceeds the specified maximal line length,
therefore we consider this case as 'the line exceeds maximal line length'
and right parenthesis will be wrapped:
public static int longMethodName | ( | int paramaterOne, | int parameterTwo | ) | { | ... | } | |
if line exceeds
too.Indentation of wrapped right parentheses ) |
See also: | Wrap before right parentheses ) |
Avoid confusing indentations for methods and constructors declarations |
int parameterTwo
is correctly aligned to parameterOne
:
public void | set(int parameterOne, | int parameterTwo) { | callAnotherMethod(paramterOne, paramaterTwo); // line is easy to miss } | |
callAnotherMethod(...)
is
easy to miss. It seems it belongs to the method declaration head. Such an indetation is
considered as 'confusing indentation'.
public void | set(int parameterOne, | |------|int parameterTwo) { | callAnotherMethod(paramterOne, paramaterTwo); // line is easy to miss } | |
callAnotherMethod(...)
is now separated from the method head and well-defined.See also: | Alternative indentation , Avoid confusing indentations |
Wrap before throws |
throws
.always
and indent by 8 white spaces:
public static void method(int args) throws Exception { callMethod(); } |
throws
to a new line
even if it would fit into the specified maximal line length.throws
is indented by setting: "Indentation of wrapped throws"never
:
public static void method(int args) throws Exception { callMethod(); } |
throws
to a new line
even if it does not fit into the specified maximal line length.on demand
and indent by 8 white spaces:
public static void method(int args) | throws Exception { | callMethod(); | } | |
throws
on demand:throws
fits into the specified maximal line length then it won't be wrapped.
If it exceeds maximal line length it will be wrapped to a new line though. The wrapped token
will be indented by setting: "Indentation of wrapped throws"if line exceeds
works a bit different:throws
belongs to exceeds maximal line length then
throws
will be wrapped.
public static void method(int args) throws Exception1, Exception2 { callMethod(); | } | |
throws
does not exceed the specified maximal line length,
but another token Exception2
does. We consider this case as 'the line exceeds
maximal line length' and therefore token throws
will be wrapped and
indented by setting: "Indentation of wrapped throws"
public static void method(int args) | throws Exception1, Exception2 { | callMethod(); | } | |
See also: | Indentation of wrapped throws |
Indentation of wrapped throws |
throws
by a specified number of white spaces.See also: | Wrap before throws |
Wrap throws exceptions |
always
:
public void method(int parameterOne) throws Exception1, Exception2, Exception3 { ... } |
never
:
public void method(int parameterOne) throws Exception1, Exception2, Exception3 { ... } |
on demand
:
public void method(int parameterOne) throws Exception1, Exception2, | Exception3 { | ... | } | |
if line exceeds
works a bit different:
public void method(int parameterOne) throws Exception1, Exception2, Exception3 { ... | } | |
Exception3
exceeds the specified maximal line length,
therefore we consider this case as 'the line exceeds maximal line length' and all
exceptions will be wrapped:
public void method(int parameterOne) throws Exception1, | Exception2, | Exception3 { | ... | } | |
Wrap lambda parameters of expressions with blocks |
Never
wrap Lambda parameters:
int sum = Arrays.stream(x) .filter((n) -> { System.out.println("Filtering: " + n); return n % 3 != 0; }) .reduce(0, Integer::sum) |
Always
wrap Lambda parameters:
int sum = Arrays.stream(x) | .filter( | (n) -> { | System.out.println("Filtering: " + n); return n % 3 != 0; | }) | .reduce(0, Integer::sum) | |
if line exceeds
:
int sum = Arrays.stream(x) | .filter( | (n) -> { | System.out.println("Filtering: " + n); | return n % 3 != 0; | }) | .reduce(0, Integer::sum) | |
See also: | Indentation of wrapped lambda parameters |
Indentation of wrapped lambda parameters |
int·sum·=·Arrays.stream(x) ················.filter( ····(n)·->·{ ························System.out.println("Filtering:·"·+·n); ························return·n·%·3·!=·0; ····················}) ················.reduce(0,·Integer::sum) |
int·sum·=·Arrays.stream(x) ················.filter( (n)·->·{ ····················System.out.println("Filtering:·"·+·n); ···················return·n·%·3·!=·0; ················}) ················.reduce(0,·Integer::sum) |
Wrap Enum constants |
on demand
:
enum Counter { | ONE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, | EIGHT, NINE, TEN | }; | |
always
:
enum Seasons { | SPRING, | SUMMER, | AUTUMN, | WINTER | }; | |
if line exceeds
:
enum Seasons { | SPRING, SUMMER, AUTUMN, WINTER | }; | | enum Counter { | ONE, | TWO, | THREE, | FOUR, | FIVE, | SIX, | SEVEN, | EIGHT, | NINE, | TEN | }; | |
Maximal number of enumeration constants lined up in one line |
enum Enum1 { ONE, TWO, THREE }; enum Enum2 { ONE, TWO, THREE, FOUR, FIVE }; enum Enum3 { ONE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN }; |
enum Enum1 { ONE, TWO, THREE }; enum Enum2 { ONE, TWO, THREE, FOUR, FIVE }; enum Enum3 { ONE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN }; |
infinite
.Wrap after left parentheses ( on demand |
Maximal number of array initializer elements lined up in one line |
int array1[] = { 1, 2, 3 }; int array2[] = { 1, 2, 3, 4, 5 }; int array3[] = { 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30 }; |
int array1[] = { 1, 2, 3 }; int array2[] = { 1, 2, 3, 4, 5 }; int array3[] = { 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30 }; |
infinite
.