Package com.github.javaparser.printer
Class PrettyPrinterConfiguration
- java.lang.Object
-
- com.github.javaparser.printer.PrettyPrinterConfiguration
-
public class PrettyPrinterConfiguration extends java.lang.Object
Configuration options for thePrettyPrinter
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PrettyPrinterConfiguration.IndentType
-
Field Summary
Fields Modifier and Type Field Description private boolean
columnAlignFirstMethodChain
private boolean
columnAlignParameters
static int
DEFAULT_MAX_ENUM_CONSTANTS_TO_ALIGN_HORIZONTALLY
private java.lang.String
endOfLineCharacter
private int
indentSize
private PrettyPrinterConfiguration.IndentType
indentType
private int
maxEnumConstantsToAlignHorizontally
private boolean
orderImports
private boolean
printComments
private boolean
printJavadoc
private int
tabWidth
private java.util.function.Function<PrettyPrinterConfiguration,VoidVisitor<java.lang.Void>>
visitorFactory
-
Constructor Summary
Constructors Constructor Description PrettyPrinterConfiguration()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getEndOfLineCharacter()
java.lang.String
getIndent()
int
getIndentSize()
PrettyPrinterConfiguration.IndentType
getIndentType()
Get the type of indent to produce.int
getMaxEnumConstantsToAlignHorizontally()
int
getTabWidth()
Get the tab width for pretty aligning.java.util.function.Function<PrettyPrinterConfiguration,VoidVisitor<java.lang.Void>>
getVisitorFactory()
boolean
isColumnAlignFirstMethodChain()
boolean
isColumnAlignParameters()
boolean
isIgnoreComments()
boolean
isOrderImports()
boolean
isPrintComments()
boolean
isPrintJavadoc()
PrettyPrinterConfiguration
setColumnAlignFirstMethodChain(boolean columnAlignFirstMethodChain)
PrettyPrinterConfiguration
setColumnAlignParameters(boolean columnAlignParameters)
PrettyPrinterConfiguration
setEndOfLineCharacter(java.lang.String endOfLineCharacter)
Set the character to append when a line should end.PrettyPrinterConfiguration
setIndentSize(int indentSize)
Set the size of the indent in characters.PrettyPrinterConfiguration
setIndentType(PrettyPrinterConfiguration.IndentType indentType)
Set the type of indent to produce.PrettyPrinterConfiguration
setMaxEnumConstantsToAlignHorizontally(int maxEnumConstantsToAlignHorizontally)
By default enum constants get aligned like this:PrettyPrinterConfiguration
setOrderImports(boolean orderImports)
When true, orders imports by alphabetically.PrettyPrinterConfiguration
setPrintComments(boolean printComments)
When true, all comments will be printed, unless printJavadoc is false, then only line and block comments will be printed.PrettyPrinterConfiguration
setPrintJavadoc(boolean printJavadoc)
When true, Javadoc will be printed.PrettyPrinterConfiguration
setTabWidth(int tabWidth)
Set the tab width for pretty aligning.PrettyPrinterConfiguration
setVisitorFactory(java.util.function.Function<PrettyPrinterConfiguration,VoidVisitor<java.lang.Void>> visitorFactory)
Set the factory that creates the PrettyPrintVisitor.
-
-
-
Field Detail
-
DEFAULT_MAX_ENUM_CONSTANTS_TO_ALIGN_HORIZONTALLY
public static final int DEFAULT_MAX_ENUM_CONSTANTS_TO_ALIGN_HORIZONTALLY
- See Also:
- Constant Field Values
-
orderImports
private boolean orderImports
-
printComments
private boolean printComments
-
printJavadoc
private boolean printJavadoc
-
columnAlignParameters
private boolean columnAlignParameters
-
columnAlignFirstMethodChain
private boolean columnAlignFirstMethodChain
-
indentType
private PrettyPrinterConfiguration.IndentType indentType
-
tabWidth
private int tabWidth
-
indentSize
private int indentSize
-
endOfLineCharacter
private java.lang.String endOfLineCharacter
-
visitorFactory
private java.util.function.Function<PrettyPrinterConfiguration,VoidVisitor<java.lang.Void>> visitorFactory
-
maxEnumConstantsToAlignHorizontally
private int maxEnumConstantsToAlignHorizontally
-
-
Method Detail
-
getIndent
public java.lang.String getIndent()
- Returns:
- the string that will be used to indent.
-
getIndentSize
public int getIndentSize()
-
setIndentSize
public PrettyPrinterConfiguration setIndentSize(int indentSize)
Set the size of the indent in characters.
-
getIndentType
public PrettyPrinterConfiguration.IndentType getIndentType()
Get the type of indent to produce.
-
setIndentType
public PrettyPrinterConfiguration setIndentType(PrettyPrinterConfiguration.IndentType indentType)
Set the type of indent to produce.
-
getTabWidth
public int getTabWidth()
Get the tab width for pretty aligning.
-
setTabWidth
public PrettyPrinterConfiguration setTabWidth(int tabWidth)
Set the tab width for pretty aligning.
-
isOrderImports
public boolean isOrderImports()
-
isPrintComments
public boolean isPrintComments()
-
isIgnoreComments
public boolean isIgnoreComments()
-
isPrintJavadoc
public boolean isPrintJavadoc()
-
isColumnAlignParameters
public boolean isColumnAlignParameters()
-
isColumnAlignFirstMethodChain
public boolean isColumnAlignFirstMethodChain()
-
setPrintComments
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.
-
setPrintJavadoc
public PrettyPrinterConfiguration setPrintJavadoc(boolean printJavadoc)
When true, Javadoc will be printed.
-
setColumnAlignParameters
public PrettyPrinterConfiguration setColumnAlignParameters(boolean columnAlignParameters)
-
setColumnAlignFirstMethodChain
public PrettyPrinterConfiguration setColumnAlignFirstMethodChain(boolean columnAlignFirstMethodChain)
-
getVisitorFactory
public java.util.function.Function<PrettyPrinterConfiguration,VoidVisitor<java.lang.Void>> getVisitorFactory()
-
setVisitorFactory
public PrettyPrinterConfiguration setVisitorFactory(java.util.function.Function<PrettyPrinterConfiguration,VoidVisitor<java.lang.Void>> visitorFactory)
Set the factory that creates the PrettyPrintVisitor. By changing this you can make the PrettyPrinter use a custom PrettyPrinterVisitor.
-
getEndOfLineCharacter
public java.lang.String getEndOfLineCharacter()
-
setEndOfLineCharacter
public PrettyPrinterConfiguration setEndOfLineCharacter(java.lang.String endOfLineCharacter)
Set the character to append when a line should end. Example values: "\n", "\r\n", "".
-
setOrderImports
public PrettyPrinterConfiguration setOrderImports(boolean orderImports)
When true, orders imports by alphabetically.
-
getMaxEnumConstantsToAlignHorizontally
public int getMaxEnumConstantsToAlignHorizontally()
-
setMaxEnumConstantsToAlignHorizontally
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.
-
-