Package com.github.javaparser.printer
Class PrettyPrinterConfiguration
- java.lang.Object
-
- com.github.javaparser.printer.PrettyPrinterConfiguration
-
public class PrettyPrinterConfiguration extends 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 static int
DEFAULT_MAX_ENUM_CONSTANTS_TO_ALIGN_HORIZONTALLY
-
Constructor Summary
Constructors Constructor Description PrettyPrinterConfiguration()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getEndOfLineCharacter()
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.Function<PrettyPrinterConfiguration,PrettyPrintVisitor>
getVisitorFactory()
boolean
isColumnAlignFirstMethodChain()
boolean
isColumnAlignParameters()
boolean
isIgnoreComments()
boolean
isOrderImports()
boolean
isPrintComments()
boolean
isPrintJavadoc()
PrettyPrinterConfiguration
setColumnAlignFirstMethodChain(boolean columnAlignFirstMethodChain)
PrettyPrinterConfiguration
setColumnAlignParameters(boolean columnAlignParameters)
PrettyPrinterConfiguration
setEndOfLineCharacter(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(Function<PrettyPrinterConfiguration,PrettyPrintVisitor> 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
-
-
Method Detail
-
getIndent
public 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 Function<PrettyPrinterConfiguration,PrettyPrintVisitor> getVisitorFactory()
-
setVisitorFactory
public PrettyPrinterConfiguration setVisitorFactory(Function<PrettyPrinterConfiguration,PrettyPrintVisitor> visitorFactory)
Set the factory that creates the PrettyPrintVisitor. By changing this you can make the PrettyPrinter use a custom PrettyPrinterVisitor.
-
getEndOfLineCharacter
public String getEndOfLineCharacter()
-
setEndOfLineCharacter
public PrettyPrinterConfiguration setEndOfLineCharacter(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.
-
-