On-demand

Lets you choose the elements that should be wrapped only when necessary. Either when the maximal line length would be exceeded otherwise or when related elements were already wrapped.

Figure 2.38. Wrapping On-demand settings page

Wrapping On-demand settings page
Wrap when exceed

Lets you enable and/or control wrapping for certain elements when the maximal line length would be exceeded without wrapping.

Import declarations

Enabling this option causes import declarations to be wrapped along the dots if otherwise the maximal line length would be exceeded. If left disabled, no line wrapping will ever occur for import declarations.

Since 1.4

Example 2.508. Very long import declaration

                                                        |
import com.mycompanyname.myprojectname.mypackagename.MyClassName;
                                                        |

Example 2.509. Wrapped import declaration

                                                        |
import com.mycompanyname.myprojectname.mypackagename    |
    .MyClassName;                                       |
Before extends keyword

When enabled, a line break is printed before the extends keyword of extends clauses when the whole clause does not fit into the current line.

Since 1.7

Example 2.510. extends clause

                                                        |
interface Testable extends Transferable, Recordable, Playable {
}                                                       |

Example 2.511. Wrapped throws clause

interface Testable                                      |
    extends Transferable, Recordable, Playable {        |
}                                                       |
Before implements keyword

When enabled, a line break is printed before the implements keyword of implements clauses when the whole clause does not fit into the current line.

Since 1.7

Example 2.512. implements clause

                                                        |
class Testable implements Transferable, Recordable, Playable {
}
                                                        |

Example 2.513. Wrapped implements clause

class Testable                                          |
    implements Transferable, Recordable, Playable {     |
}                                                       |
Before throws keyword

When enabled, a line break is printed before the keyword keyword of throws clauses when the whole clause does not fit into the current line.

Since 1.7

Example 2.514. throws clause

                                                        |
public void performaAction() throws InvalidStateException {
}
                                                        |

Example 2.515. Wrapped throws clause

public void performaAction()                            |
    throws InvalidStateException {                      |
}                                                       |
Marker annotations

When enabled, a line break will be inserted after the last marker annotation, when no other Java modifiers appear before the annotation and the declaration the annotation is part of, does not fit into the current line length limit.

Since 1.7

Example 2.516. No line break after marker annotation

                                                       |
@Preliminary interface Testable extends Transferable,  |
    Recordable {                                       |
    ...                                                |
}                                                      |

Example 2.517. Line break after marker annotation

@Preliminary                                           |
interface Testable extends Transferable, Recordable {  |
    ...                                                |
}                                                      |

Please note that wrapping after the marker annotation only occurs, if other modifiers appear before the annotation!

Example 2.518. 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.

Related options:

Field declaration names

Issues a line break before the name of a field declaration when the maximal line length would be exceeded otherwise.

Since 1.7

Example 2.519. Field declaration which exceeds line length

public static final InputMethodHighlight UNSELECTED_TEXT_HIGHLIGHTS =
    new InputMethodHighlight(false, CONVERTED_TEXT);          |

Example 2.520. Wrapped method declaration

public static final InputMethodHighlight                      |
     UNSELECTED_TEXT_HIGHLIGHTS =                             |
         new InputMethodHighlight(false, CONVERTED_TEXT);     |
Method declaration names

Issues a line break before the name of a method or constructor declaration when the maximal line length would be exceeded otherwise.

Since 1.3

Example 2.521. Method declaration which exceeds line length

protected PropertyChangeListener createPropertyChangeListener() {
}                                                             |

Example 2.522. Wrapped method declaration

protected PropertyChangeListener                              |
createPropertyChangeListener() {                              |
}                                                             |
After assignments

Lets you control the way wrapping takes action for assignments. If left disabled, line wrapping preferably occurs as part of the expression printing. Otherwise wrapping will be performed right after the assignment whenever the expression cannot be printed in just one line.

Example 2.523. Prefer wrap along the expression

this.interessentenNr = new InteressentenNr(
        Fachschluesselerzeugung.createService()
        .getNeuerFachschluessel(
            FachschluesselerzeugungService.FACHSCHLUESSEL_KZ_INTERESSENT
        )
    );

Example 2.524. Prefer wrap after assignment

this.interessentenNr =
    new InteressentenNr(
        Fachschluesselerzeugung.createService()
        .getNeuerFachschluessel(
            FachschluesselerzeugungService.FACHSCHLUESSEL_KZ_INTERESSENT
        )
    );
After "return" statement

Lets you control the wrapping behavior for return statements. If enabled, a line break is inserted after the return statment when the expression would exceed the maximal line length.

Since 1.2.1

Example 2.525. return statement

return ((getKey() == null) ? (other.getKey() == null)           |
                           : getKey().equals(other.getKey()));  |

Example 2.526. Prefer wrapping after return statement

return                                                          |
    ((getKey() == null) ? (other.getKey() == null)              |
                        : getKey().equals(other.getKey()));     |
After left parenthesis

Lets you control the wrapping behavior for parameter, statement and expression lists.

If left disabled, the first line break will be preferably inserted behind the first parameter or expression and only occurs after the left parenthesis if the maximal line length would be otherwise exceeded.

Example 2.527. Wrap after left parenthesis (disabled)

appServerReferencesVector.add(new AppServerReference(
        "RemoteApplicationManager",
        poa.create_reference_with_id(
            "RemoteApplicationManager".getBytes(),
            RemoteApplicationManagerHelper.id())));

When enabled, the line break will always occur behind the left parenthesis when the list parameters, arguments or expressions cannot be printed in just one line.

Example 2.528. Wrap after left parenthesis (enabled)

appServerReferencesVector.add(
    new AppServerReference(
        "RemoteApplicationManager",
        poa.create_reference_with_id(
            "RemoteApplicationManager".getBytes(),
            RemoteApplicationManagerHelper.id())));

This option affects the output style of method/constructor declarations and calls, creator calls and if-else, for, while and do-while blocks.

As per default, the wrapped lines will be indented using standard indentation, but you may want to apply another indentation scheme. See the section called "Strategies" for more information.

Before right parenthesis

Prints a line break before the right parenthesis of parameter or expression lists when at least one parameter/expression was wrapped. The parenthesis will be intended according to the current indentation level.

This switch affects the output style of method/constructor declarations and calls, creator calls and if-else, for, while and do-while blocks.

Example 2.529. Right parenthesis (disabled)

public void severalParameters(String one,
                              int two,
                              String three,
                              StringObject four,
                              AnotherObject five) {
}

Example 2.530. Right parenthesis (enabled)

public void severalParameters(String one,
                              int two,
                              String three,
                              StringObject four,
                              AnotherObject five
) {
}

Both switches combined, looks like the following example:

Example 2.531. Left and right parenthesis

appServerReferencesVector.add(
    new AppServerReference(
        "RemoteApplicationManager",
        poa.create_reference_with_id(
            "RemoteApplicationManager".getBytes(),
            RemoteApplicationManagerHelper.id()
        )
    )
);

For blocks the output may go like this:

Example 2.532. Left and right parenthesis (wrapped)

if (
    "pick".equals(m.getName()) && m.isStatic() && m.isPublic()
) {
    pickFound = true;
} else if (
    "pick".equals(m.getName()) && m.isStatic() && m.isPublic()
) {
    pickFound = true;
}
Grouping parentheses

Lets you control the wrapping behavior for grouping parentheses. If enabled, line breaks are inserted after left and before right parentheses of grouped expressions to let the expression(s) stand out.

Example 2.533. Grouping parentheses (standard indented)

if (
    !((bankverbindung instanceof ObjectValue)
    || (bankverbindung instanceof PrimitiveValue))
) {
    throw new RuntimeException();
}

Example 2.534. Wrapped grouping parentheses (standard indented)

if (
    !(
        (bankverbindung instanceof ObjectValue)
        || (bankverbindung instanceof TkPrimitiveValue)
    )
) {
    throw new RuntimeException();
}
Type parameter

When enabled, type parameters of parameterized (generic) types are wrapped, when necessary.

Since 1.4

Example 2.535. Parameterized type that lead to exceeded maximal line length

                                                                      |
private final Map<Short, String> example = new HashMap<Short, String>();
                                                                      |

Example 2.536. Wrapped parameterized type (endline indented)

                                                                      |
private final Map<Short, String> example = new HashMap<Short,         |
                                                       String>();     |
                                                                      |

Please note that with Endline indentation enabled, wrapping only happens if both type parameter names are either not single-lettered or contain one ore more bounds.

Example 2.537. Exceptions when using endline indentation

                                                     |
public class Test<A, B extends Comparable<B> & Cloneable> {
}                                                    |
Within call after assignment

This option lets you define where a line wrap should preferably occur for call statements after assignments that don't fit into the maximal line length.

This is option is only meant to let you adjust behavior when "Prefer wrap after assignments" has been enabled. Please see explanation there.

Since 1.7

Example 2.538. Wrapping assignment expression

nuMBeans =
     NuvegaPropertiesHandler.getNNuvegaArrayProperty(
         NuvegaProperties.PROPERTIES_FILE_NUVEGA_BEAN_NAME);

Example 2.539. Prefer wrapping within call

nuMBeans = NuvegaPropertiesHandler.getNNuvegaArrayProperty(
         NuvegaProperties.PROPERTIES_FILE_NUVEGA_BEAN_NAME);
Within call arguments

This option lets you define where a line wrap should preferably occur for call arguments that does not fit into the maximal line length.

Normally a line gets wrapped before a call argument that don't fit into the maximal line length. Enabling this option will cause a line break inserted within the call argument for operator expressions when the operator expression is not immediately preceded with or followed by another operator expression.

Since 1.5

Example 2.540. Wrapping method call (default behavior)

failed(output, "a" + "b", null,                           |
        "Failed to open prefs: " + e.getMessage());       | 
                                                          |

As you can see from the above example a line break is inserted before the third argument as it would exceed the maximal line length when printed in the same line.

Example 2.541. Prefer wrapping within call argument

failed(output, "a" + "b", null, "Failed to open prefs: "  |
       + e.getMessage());                                 |
                                                          |

When the option is enabled, the line break happens within along the operator of the third argument.

Example 2.542. Standard wrapping when two operator expressions

failed(output, "a" + "b",                                 |
       "Failed to open prefs: " + e.getMessage());        |
                                                          |

But if two operator expressions follow immediately, the standard behavior applies in order to enhance readibility.