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 classPrettyPrinterConfiguration.IndentType
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_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 StringgetEndOfLineCharacter()StringgetIndent()intgetIndentSize()PrettyPrinterConfiguration.IndentTypegetIndentType()Get the type of indent to produce.intgetMaxEnumConstantsToAlignHorizontally()intgetTabWidth()Get the tab width for pretty aligning.Function<PrettyPrinterConfiguration,PrettyPrintVisitor>getVisitorFactory()booleanisColumnAlignFirstMethodChain()booleanisColumnAlignParameters()booleanisIgnoreComments()booleanisOrderImports()booleanisPrintComments()booleanisPrintJavadoc()PrettyPrinterConfigurationsetColumnAlignFirstMethodChain(boolean columnAlignFirstMethodChain)PrettyPrinterConfigurationsetColumnAlignParameters(boolean columnAlignParameters)PrettyPrinterConfigurationsetEndOfLineCharacter(String endOfLineCharacter)Set the character to append when a line should end.PrettyPrinterConfigurationsetIndentSize(int indentSize)Set the size of the indent in characters.PrettyPrinterConfigurationsetIndentType(PrettyPrinterConfiguration.IndentType indentType)Set the type of indent to produce.PrettyPrinterConfigurationsetMaxEnumConstantsToAlignHorizontally(int maxEnumConstantsToAlignHorizontally)By default enum constants get aligned like this:PrettyPrinterConfigurationsetOrderImports(boolean orderImports)When true, orders imports by alphabetically.PrettyPrinterConfigurationsetPrintComments(boolean printComments)When true, all comments will be printed, unless printJavadoc is false, then only line and block comments will be printed.PrettyPrinterConfigurationsetPrintJavadoc(boolean printJavadoc)When true, Javadoc will be printed.PrettyPrinterConfigurationsetTabWidth(int tabWidth)Set the tab width for pretty aligning.PrettyPrinterConfigurationsetVisitorFactory(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.
-
-