Top Description Inners Fields Constructors Methods
com.github.javaparser.printer

public Class PrettyPrinterConfiguration

extends Object
Class Inheritance
Imports
com.github.javaparser.ast.visitor.VoidVisitor, java.util.function.Function

Configuration options for the PrettyPrinter.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum

Field Summary

Modifier and TypeField and Description
private boolean
private boolean
public static final int
private String
private int
private PrettyPrinterConfiguration.IndentType
private int
private boolean
private boolean
private boolean
private int
private Function<PrettyPrinterConfiguration, VoidVisitor<Void>>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public String
public String

Returns:

the string that will be used to indent.
getIndent
()

public int
public PrettyPrinterConfiguration.IndentType
getIndentType()

Get the type of indent to produce.

public int
public int
getTabWidth()

Get the tab width for pretty aligning.

public Function<PrettyPrinterConfiguration, VoidVisitor<Void>>
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public PrettyPrinterConfiguration
setColumnAlignFirstMethodChain(boolean columnAlignFirstMethodChain)

public PrettyPrinterConfiguration
setColumnAlignParameters(boolean columnAlignParameters)

public PrettyPrinterConfiguration
setEndOfLineCharacter(String endOfLineCharacter)

Set the character to append when a line should end.

public PrettyPrinterConfiguration
setIndentSize(int indentSize)

Set the size of the indent in characters.

public PrettyPrinterConfiguration
setIndentType(PrettyPrinterConfiguration.IndentType indentType)

Set the type of indent to produce.

public PrettyPrinterConfiguration
setMaxEnumConstantsToAlignHorizontally(int maxEnumConstantsToAlignHorizontally)

By default enum constants get aligned like this:

    enum X {
       A, B, C, D
    }
public PrettyPrinterConfiguration
setOrderImports(boolean orderImports)

When true, orders imports by alphabetically.

public PrettyPrinterConfiguration
setPrintComments(boolean printComments)

When true, all comments will be printed, unless printJavadoc is false, then only line and block comments will be printed.

public PrettyPrinterConfiguration
setPrintJavadoc(boolean printJavadoc)

When true, Javadoc will be printed.

public PrettyPrinterConfiguration
setTabWidth(int tabWidth)

Set the tab width for pretty aligning.

public PrettyPrinterConfiguration
setVisitorFactory(Function<PrettyPrinterConfiguration, VoidVisitor<Void>> visitorFactory)

Set the factory that creates the PrettyPrintVisitor.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

columnAlignFirstMethodChainback to summary
private boolean columnAlignFirstMethodChain
columnAlignParametersback to summary
private boolean columnAlignParameters
DEFAULT_MAX_ENUM_CONSTANTS_TO_ALIGN_HORIZONTALLYback to summary
public static final int DEFAULT_MAX_ENUM_CONSTANTS_TO_ALIGN_HORIZONTALLY
endOfLineCharacterback to summary
private String endOfLineCharacter
indentSizeback to summary
private int indentSize
indentTypeback to summary
private PrettyPrinterConfiguration.IndentType indentType
maxEnumConstantsToAlignHorizontallyback to summary
private int maxEnumConstantsToAlignHorizontally
orderImportsback to summary
private boolean orderImports
printCommentsback to summary
private boolean printComments
printJavadocback to summary
private boolean printJavadoc
tabWidthback to summary
private int tabWidth
visitorFactoryback to summary
private Function<PrettyPrinterConfiguration, VoidVisitor<Void>> visitorFactory

Constructor Detail

PrettyPrinterConfigurationback to summary
public PrettyPrinterConfiguration()

Method Detail

getEndOfLineCharacterback to summary
public String getEndOfLineCharacter()
getIndentback to summary
public String getIndent()
Returns:String

the string that will be used to indent.

getIndentSizeback to summary
public int getIndentSize()
getIndentTypeback to summary
public PrettyPrinterConfiguration.IndentType getIndentType()

Get the type of indent to produce.

getMaxEnumConstantsToAlignHorizontallyback to summary
public int getMaxEnumConstantsToAlignHorizontally()
getTabWidthback to summary
public int getTabWidth()

Get the tab width for pretty aligning.

getVisitorFactoryback to summary
public Function<PrettyPrinterConfiguration, VoidVisitor<Void>> getVisitorFactory()
isColumnAlignFirstMethodChainback to summary
public boolean isColumnAlignFirstMethodChain()
isColumnAlignParametersback to summary
public boolean isColumnAlignParameters()
isIgnoreCommentsback to summary
public boolean isIgnoreComments()
isOrderImportsback to summary
public boolean isOrderImports()
isPrintCommentsback to summary
public boolean isPrintComments()
isPrintJavadocback to summary
public boolean isPrintJavadoc()
setColumnAlignFirstMethodChainback to summary
public PrettyPrinterConfiguration setColumnAlignFirstMethodChain(boolean columnAlignFirstMethodChain)
setColumnAlignParametersback to summary
public PrettyPrinterConfiguration setColumnAlignParameters(boolean columnAlignParameters)
setEndOfLineCharacterback to summary
public PrettyPrinterConfiguration setEndOfLineCharacter(String endOfLineCharacter)

Set the character to append when a line should end. Example values: "\n", "\r\n", "".

setIndentSizeback to summary
public PrettyPrinterConfiguration setIndentSize(int indentSize)

Set the size of the indent in characters.

setIndentTypeback to summary
public PrettyPrinterConfiguration setIndentType(PrettyPrinterConfiguration.IndentType indentType)

Set the type of indent to produce.

setMaxEnumConstantsToAlignHorizontallyback to summary
public PrettyPrinterConfiguration setMaxEnumConstantsToAlignHorizontally(int maxEnumConstantsToAlignHorizontally)

By default enum constants get aligned like this:

    enum X {
       A, B, C, D
    }
until the amount of constants passes this value (5 by default). Then they get aligned like this:
    enum X {
       A,
       B,
       C,
       D,
       E,
       F,
       G
    }
Set it to a large number to always align horizontally. Set it to 1 or less to always align vertically.
setOrderImportsback to summary
public PrettyPrinterConfiguration setOrderImports(boolean orderImports)

When true, orders imports by alphabetically.

setPrintCommentsback to summary
public PrettyPrinterConfiguration setPrintComments(boolean printComments)

When true, all comments will be printed, unless printJavadoc is false, then only line and block comments will be printed.

setPrintJavadocback to summary
public PrettyPrinterConfiguration setPrintJavadoc(boolean printJavadoc)

When true, Javadoc will be printed.

setTabWidthback to summary
public PrettyPrinterConfiguration setTabWidth(int tabWidth)

Set the tab width for pretty aligning.

setVisitorFactoryback to summary
public PrettyPrinterConfiguration setVisitorFactory(Function<PrettyPrinterConfiguration, VoidVisitor<Void>> visitorFactory)

Set the factory that creates the PrettyPrintVisitor. By changing this you can make the PrettyPrinter use a custom PrettyPrinterVisitor.

com.github.javaparser.printer back to summary

public final Enum PrettyPrinterConfiguration.IndentType

extends Enum<PrettyPrinterConfiguration.IndentType>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final PrettyPrinterConfiguration.IndentType
SPACES

Indent with spaces.

public static final PrettyPrinterConfiguration.IndentType
TABS

Indent with tabs as far as possible.

public static final PrettyPrinterConfiguration.IndentType
TABS_WITH_SPACE_ALIGN

Indent with tabs but align with spaces when wrapping and aligning method call chains and method call parameters.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static PrettyPrinterConfiguration.IndentType
public static PrettyPrinterConfiguration.IndentType[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

SPACESback to summary
public static final PrettyPrinterConfiguration.IndentType SPACES

Indent with spaces.

TABSback to summary
public static final PrettyPrinterConfiguration.IndentType TABS

Indent with tabs as far as possible. For proper aligning, the tab width is necessary and by default 4.

TABS_WITH_SPACE_ALIGNback to summary
public static final PrettyPrinterConfiguration.IndentType TABS_WITH_SPACE_ALIGN

Indent with tabs but align with spaces when wrapping and aligning method call chains and method call parameters.

Example result:

class Foo {

\tvoid bar() {
\t\tfoo().bar()
\t\t......baz(() -> {
\t\t..........\tboo().baa()
\t\t..........\t......bee(a,
\t\t..........\t..........b,
\t\t..........\t..........c);
\t\t..........})
\t\t......bam();
\t}
}

Constructor Detail

IndentTypeback to summary
private IndentType()

Method Detail

valueOfback to summary
public static PrettyPrinterConfiguration.IndentType valueOf(String name)
valuesback to summary
public static PrettyPrinterConfiguration.IndentType[] values()