Always

Lets you choose the elements that should be wrapped always.

Figure 2.37. Wrapping Always settings page

Wrapping Always settings page
Wrap always

For certain cases, the need may arise to force line wrapping to achieve a consistent, uniform look. If you enable any of the following switches, line wrapping will occur for the specified cases no matter whether you have enabled general line wrapping or not.

Before declaration keywords

Forces a line break before the class, interface keyword, enum and @interface keywords.

Since 1.4

Example 2.456. Class declaration

public class FooBar {
    ...
}

Example 2.457. Wrapped class declaration

public
class FooBar {
    ...
}
After "class" keyword

Forces a line break after the class keyword.

Since 1.3

Example 2.458. Class declaration

public class FooBar {
    ...
}

Example 2.459. Wrapped class declaration

public class
FooBar {
    ...
}
Before extends keyword

Forces a line break before the extends keyword of a class/interface declaration.

Example 2.460. Class/interface extends keyword

public interface Channel extends Puttable, Takable {
    ...
}

Example 2.461. Wrapped class/interface extends keyword (Standard indented)

public interface Channel
    extends Puttable, Takable {
    ...
}

You can control the space printed before the keyword via the indentation settings. See "Extends indent size" for more information.

After extends types

Forces a line wrap after each type name of the extended classes.

Example 2.462. Class/interface extends types

public interface Channel extends Puttable, Takable {
    ...
}

Example 2.463. Wrapped class/interface extends types (Endline indented)

public interface Channel extends Puttable,
                                 Takable {
    ...
}
Before implements keyword

Forces a line break before the implements keyword of a class declaration.

Example 2.464. implements keyword

public class SynchronizedBoolean implements Comparable, Cloneable {
    ...
}

Example 2.465. Wrapped implements keyword (Standard indented)

public class SynchronizedBoolean
    implements Comparable, Cloneable {
    ...
}

You can control the space printed before the keyword via the indentation settings. See "Implements indent size" for more information.

After implements types

Forces a line wrap after each type name of the implemented classes.

Example 2.466. Class implements types

public class SynchronizedBoolean implements Comparable, Cloneable {
    ...
}

Example 2.467. Wrapped class implements types (Endline indented)

public class SynchronizedBoolean implements Comparable,
                                            Cloneable {
    ...
}
Before throws keyword

Forces a line break before the throws keyword of a method/constructor declaration.

Example 2.468. throws keyword

private File getDestinationFile(File dest, String packageName,
                                String filename) throws IOException {
    ...
}

Example 2.469. Wrapped throws keyword (Endline indented)

private File getDestinationFile(File dest, String packageName,
                                String filename)
                         throws IOException {
    ...
}

You can control the space printed before the keyword via the indentation settings. See "Throws indent size" for more information.

After throws keyword

Forces a line break after the throws keyword.

Since 1.3

Example 2.470. Throws signature

public void foo()
    throws FooException,
        BarException {
    ...
}

Example 2.471. Throws signature (wrapped)

public void foo()
    throws
        FooException,
        BarException {
    ...
}
After throws types

Forces a line wrap after each type name of the throws clause of a method/constructor declaration.

Example 2.472. throws types

private File getDestinationFile(File dest, String packageName,
                                String filename)
                         throws IOException, FooException {
    ...
}

Example 2.473. Wrapped throws types (Standard indented)

private static final File getDestinationFile(File dest, String packageName,
                                             String filename)
    throws IOException,
        FooException {
    ...
}

Example 2.474. Wrapped throws types (Endline indented)

private File getDestinationFile(File dest, String packageName,
                                String filename)
                         throws IOException,
                                FooException {
    ...
}
Enum constants

When ennabled, forces a line break after each enum constant of an enum declaration.

Since 1.2

Example 2.475. Enum constants

public enum Season {
    WINTER, SPRING, SUMMER, FALL
}

Example 2.476. Forced line break after enum constants

public enum Season {
    WINTER,
    SPRING,
    SUMMER,
    FALL
}
Marker annotations

When enabled, a line break will be inserted after the last marker annotation, when no other Java modifiers appear before the annotation.

Since 1.1

Example 2.477. No line break after marker annotation

@Preliminary public class TimeTravel {
    ...
}

Example 2.478. Line break after marker annotation

@Preliminary
public class TimeTravel {
    ...
}

Example 2.479. No line break after marker annotation when modifier(s) before

public @Preliminary class TimeTravel {
    ...
}

You can ensure that marker annotations appear before other Java modifiers via the modifiers sorting settings, see the section called "Sort Order" for more information.

Annotation members

When enabled, a line break will be inserted after each member of a normal annotation. Additionally, line breaks will occur after the left and before the right parenthesis.

Otherwise, a line break after a member value pair only happens when the maximal line would be exceeded. Line breaks after left and before right parenthesis are only printed when all members does not fit into one line.

Since 1.5

Example 2.480. Line breaks after annotation members

@Author(
    @Name(
        first = "Joe",
        last = "Hacker"
    )
)
public class BitTwiddle { ... }

Example 2.481. No line break after members

@Author(@Name(first = "Joe", last = "Hacker"))
public class BitTwiddle { ... }

Example 2.482. No line break after members

@Author(                                                        |
    @Name(first = "Joe", last = "Hacker", location = "Redmond") |
)                                                               |
public class BitTwiddle { ... }                                 |
Field declaration names

Forces a line wrap before the name of an instance field declaration. Please note that this option does not apply for multi-variables.

Since 1.2

Example 2.483. Field declaration

private int _count = 0

Example 2.484. Field declaration with line break between before the name

private int
_count = 0
Method declaration names

Forces a line wrap before the name of a method or constructor declaration.

Since 1.0.3

Example 2.485. Method declaration

public static int foo()
{
    ...
}

Example 2.486. Method declaration with line break between return type and name

public static int
foo()
{
    ...
}
Declaration parameters

Forces a line break after each parameter of a method or constructor declaration.

Example 2.487. Method declaration parameters

public static File create(File file, File directory, int backupLevel)
                   throws IOException {
    ...
}

Example 2.488. Wrapped method declaration parameters (Endline indented)

public static File create(File file,
                          File directory,
                          int backupLevel)
                   throws IOException {
    ...
}
Call arguments

Forces a line wrap after each argument of a method call.

Example 2.489. Method call

doSomething();
_userDatabase.addUser("Name", encryptPassword("password", _secretKey),
                      "123 fake address");
doSomethingElse();

Example 2.490. Wrapped method call (Endline indented)

doSomething();
_userDatabase.addUser("Name",
                      encryptPassword("password",
                                      _secretKey),
                      "123 fake address");
doSomethingElse();
Nested call arguments

Forces a line wrap after each argument of a method call if at least one argument is a method call itself. This option can prove especially useful if one prefers to nest method calls as arguments rather than adding local variables just to hold those arguments.

Example 2.491. Wrapped nested method call (Endline indented)

doSomething();
_userDatabase.addUser("Name",
                      encryptPassword("password", _secretKey),
                      "123 fake address");
doSomethingElse();
Chained method calls

Forces a line wrap after each chained method call.

Example 2.492. Chained method call

message.format(ERROR_SOURCE_ADDRESS).param (m_session.getAimName()).send();

Example 2.493. Wrapped chained method call (aligned)

message.format(ERROR_SOURCE_ADDRESS)
       .param (m_session.getAimName())
       .send();

Please note that you can control the aligment for chained method calls with the "Align chained method call" option.

Nested chained method calls

Forces a line wrap after each method call chain of nested method calls, i.e. method calls used as call arguments.

Example 2.494. Chained method call

message.format(ERROR_SOURCE_ADDRESS).param (m_session.getAimName()).send();

Example 2.495. Wrapped chained method call (aligned)

message.format(ERROR_SOURCE_ADDRESS)
       .param (m_session.getAimName())
       .send();

Please note that you can control the aligment for chained method calls with the "Align chained method call" option.

Since 1.6

Multi variable types

When enabled, a line break will be printed after the type identifier of the declaration.

Since 1.0

Example 2.496. Standard multi-variable

BigInteger q = null, p = null, g = null;

Example 2.497. Force wrap after type of multi-variables (Standard indented)

BigInteger
    q = null, p = null, g = null;
Multi variable declarators

When enabled, each declaration of a multi-variable declaration gets always printed on a new line. Otherwise, wrapping only occurs when necessary.

Since 1.0

Example 2.498. Standard multi-variable

BigInteger q = null, p = null, g = null;

Example 2.499. Force wrap after each declarator of multi-variables (Endline indented)

BigInteger q = null,
           p = null,
           g = null;
Ternary expression question mark (?)

Forces a line wrap after the first operand.

Example 2.500. Wrapped ternary expression question mark (Endline indented)

String comma = spaceAfterComma
               ? COMMA_SPACE : COMMA;

Indentation for consecutive lines depends on the used indentation scheme. See the section called "Strategies" for more information. You may further want to use continuation indentation.

Ternary expression colon (:)

Forces a line wrap after the second operand.

Example 2.501. Wrapped ternary expression colon (Endline indented)

String comma = spaceAfterComma ? COMMA_SPACE
                               : COMMA;

If both switches are disabled, ternary expressions are printed in one line (if everything fits in one line, that is).

Example 2.502. Ternary expressions

String comma = spaceAfterComma ? COMMA_SPACE : COMMA;

If both switches are enabled, you can force a style like the following:

Example 2.503. Wrapped ternary expressions (Standard indented)

String comma = spaceAfterComma
    ? COMMA_SPACE
    : COMMA;
Labels

Forces a line wrap after labels.

Example 2.504. Label

// advance to the first CLASS_DEF or INTERFACE_DEF
LOOP:   for (AST child = tree.getFirstChild();
             child != null;
             child = child.getNextSibling()) {
            switch (child.getType()) {
                case JavaTokenTypes.CLASS_DEF :
                case JavaTokenTypes.INTERFACE_DEF :
                    next = child;
                    break LOOP;

                default :
                    break;
            }
        }

Example 2.505. Wrapped label (Standard indented)

// advance to the first CLASS_DEF or INTERFACE_DEF
LOOP:
        for (AST child = tree.getFirstChild();
             child != null;
             child = child.getNextSibling()) {
            switch (child.getType()) {
                case JavaTokenTypes.CLASS_DEF :
                case JavaTokenTypes.INTERFACE_DEF :
                    next = child;
                    break LOOP;

                default :
                    break;
            }
        }
Registry Keys

Forces line wrapping after assignments for constants whose names ends with the "Registry" suffix.

Since 1.7

Example 2.506. Registry keys

class FooRegistry {
    boolean ALLOW_FAKE_FOOS = Registry.contains(KEY_FAKE_FOOS);
}

Example 2.507. Registry keys (wrapping forced)

class FooRegistry {
    boolean ALLOW_FAKE_FOOS =
        Registry.contains(KEY_FAKE_FOOS);
}