|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
|
|
package com.github.javaparser.printer.configuration; |
|
|
|
import static com.github.javaparser.utils.Utils.assertNonNegative; |
|
import static com.github.javaparser.utils.Utils.assertNotNull; |
|
import static com.github.javaparser.utils.Utils.assertPositive; |
|
|
|
import java.util.Optional; |
|
import java.util.Set; |
|
|
|
import com.github.javaparser.printer.PrettyPrinter; |
|
import com.github.javaparser.printer.configuration.DefaultPrinterConfiguration.ConfigOption; |
|
import com.github.javaparser.printer.configuration.Indentation.IndentType; |
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
@Deprecated |
|
public class PrettyPrinterConfiguration implements PrinterConfiguration { |
|
|
|
|
|
PrinterConfiguration wrappedConfiguration; |
|
|
|
|
|
|
|
*/ |
|
public PrettyPrinterConfiguration() { |
|
this.wrappedConfiguration = new DefaultPrinterConfiguration(); |
|
} |
|
|
|
|
|
|
|
*/ |
|
public Indentation getIndentation() { |
|
return wrappedConfiguration.get(new DefaultConfigurationOption(ConfigOption.INDENTATION)).get().asValue(); |
|
} |
|
|
|
public PrettyPrinterConfiguration setIndentation(Indentation indentation) { |
|
wrappedConfiguration.addOption(new DefaultConfigurationOption(ConfigOption.INDENTATION, indentation)); |
|
return this; |
|
} |
|
|
|
|
|
|
|
|
|
*/ |
|
@Deprecated |
|
public String getIndent() { |
|
return getIndentation().getIndent(); |
|
} |
|
|
|
|
|
|
|
|
|
*/ |
|
@Deprecated |
|
public int getIndentSize() { |
|
return getIndentation().getSize(); |
|
} |
|
|
|
|
|
|
|
|
|
*/ |
|
@Deprecated |
|
public PrettyPrinterConfiguration setIndentSize(int indentSize) { |
|
Indentation indentation = getIndentation().setSize(assertNonNegative(indentSize)); |
|
setIndentation(indentation); |
|
return this; |
|
} |
|
|
|
|
|
|
|
|
|
*/ |
|
@Deprecated |
|
public IndentType getIndentType() { |
|
return getIndentation().getType(); |
|
} |
|
|
|
|
|
|
|
|
|
*/ |
|
@Deprecated |
|
public PrettyPrinterConfiguration setIndentType(IndentType indentType) { |
|
Indentation indentation = getIndentation().setType(assertNotNull(indentType)); |
|
setIndentation(indentation); |
|
return this; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
@Deprecated |
|
public int getTabWidth() { |
|
return getIndentation().getSize(); |
|
} |
|
|
|
|
|
|
|
|
|
*/ |
|
@Deprecated |
|
public PrettyPrinterConfiguration setTabWidth(int tabWidth) { |
|
setIndentSize(assertPositive(tabWidth)); |
|
return this; |
|
} |
|
|
|
public boolean isOrderImports() { |
|
return wrappedConfiguration.get(new DefaultConfigurationOption(ConfigOption.ORDER_IMPORTS)).isPresent(); |
|
} |
|
|
|
public boolean isPrintComments() { |
|
return wrappedConfiguration.get(new DefaultConfigurationOption(ConfigOption.PRINT_COMMENTS)).isPresent(); |
|
} |
|
|
|
public boolean isIgnoreComments() { |
|
return !wrappedConfiguration.get(new DefaultConfigurationOption(ConfigOption.PRINT_COMMENTS)).isPresent(); |
|
} |
|
|
|
public boolean isSpaceAroundOperators() { |
|
return wrappedConfiguration.get(new DefaultConfigurationOption(ConfigOption.SPACE_AROUND_OPERATORS)).isPresent(); |
|
} |
|
|
|
public boolean isPrintJavadoc() { |
|
return wrappedConfiguration.get(new DefaultConfigurationOption(ConfigOption.PRINT_JAVADOC)).isPresent(); |
|
} |
|
|
|
public boolean isColumnAlignParameters() { |
|
return wrappedConfiguration.get(new DefaultConfigurationOption(ConfigOption.COLUMN_ALIGN_PARAMETERS)).isPresent(); |
|
} |
|
|
|
public boolean isColumnAlignFirstMethodChain() { |
|
return wrappedConfiguration.get(new DefaultConfigurationOption(ConfigOption.COLUMN_ALIGN_FIRST_METHOD_CHAIN)).isPresent(); |
|
} |
|
|
|
public boolean isIndentCaseInSwitch() { |
|
return wrappedConfiguration.get(new DefaultConfigurationOption(ConfigOption.INDENT_CASE_IN_SWITCH)).isPresent(); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public PrettyPrinterConfiguration setPrintComments(boolean printComments) { |
|
wrappedConfiguration = printComments ? |
|
addOption(new DefaultConfigurationOption(ConfigOption.PRINT_COMMENTS)) : |
|
removeOption(new DefaultConfigurationOption(ConfigOption.PRINT_COMMENTS)); |
|
return this; |
|
} |
|
|
|
|
|
|
|
*/ |
|
public PrettyPrinterConfiguration setPrintJavadoc(boolean printJavadoc) { |
|
wrappedConfiguration = printJavadoc ? |
|
addOption(new DefaultConfigurationOption(ConfigOption.PRINT_JAVADOC)) : |
|
removeOption(new DefaultConfigurationOption(ConfigOption.PRINT_JAVADOC)); |
|
return this; |
|
} |
|
|
|
|
|
|
|
*/ |
|
public PrettyPrinterConfiguration setSpaceAroundOperators(boolean spaceAroundOperators){ |
|
wrappedConfiguration = spaceAroundOperators ? |
|
addOption(new DefaultConfigurationOption(ConfigOption.SPACE_AROUND_OPERATORS)) : |
|
removeOption(new DefaultConfigurationOption(ConfigOption.SPACE_AROUND_OPERATORS)); |
|
return this; |
|
} |
|
|
|
public PrettyPrinterConfiguration setColumnAlignParameters(boolean columnAlignParameters) { |
|
wrappedConfiguration = columnAlignParameters ? |
|
addOption(new DefaultConfigurationOption(ConfigOption.COLUMN_ALIGN_PARAMETERS)) : |
|
removeOption(new DefaultConfigurationOption(ConfigOption.COLUMN_ALIGN_PARAMETERS)); |
|
return this; |
|
} |
|
|
|
public PrettyPrinterConfiguration setColumnAlignFirstMethodChain(boolean columnAlignFirstMethodChain) { |
|
wrappedConfiguration = columnAlignFirstMethodChain ? |
|
addOption(new DefaultConfigurationOption(ConfigOption.COLUMN_ALIGN_FIRST_METHOD_CHAIN)) : |
|
removeOption(new DefaultConfigurationOption(ConfigOption.COLUMN_ALIGN_FIRST_METHOD_CHAIN)); |
|
return this; |
|
} |
|
|
|
public PrettyPrinterConfiguration setIndentCaseInSwitch(boolean indentInSwitch) { |
|
wrappedConfiguration = indentInSwitch ? |
|
addOption(new DefaultConfigurationOption(ConfigOption.INDENT_CASE_IN_SWITCH)) : |
|
removeOption(new DefaultConfigurationOption(ConfigOption.INDENT_CASE_IN_SWITCH)); |
|
return this; |
|
} |
|
|
|
public String getEndOfLineCharacter() { |
|
return wrappedConfiguration.get(new DefaultConfigurationOption(ConfigOption.END_OF_LINE_CHARACTER)).get().asValue(); |
|
} |
|
|
|
|
|
|
|
*/ |
|
public PrettyPrinterConfiguration setEndOfLineCharacter(String endOfLineCharacter) { |
|
addOption(new DefaultConfigurationOption(ConfigOption.END_OF_LINE_CHARACTER, endOfLineCharacter)); |
|
return this; |
|
} |
|
|
|
|
|
|
|
*/ |
|
public PrettyPrinterConfiguration setOrderImports(boolean orderImports) { |
|
wrappedConfiguration = orderImports ? |
|
addOption(new DefaultConfigurationOption(ConfigOption.ORDER_IMPORTS)) : removeOption(new DefaultConfigurationOption(ConfigOption.ORDER_IMPORTS)); |
|
return this; |
|
} |
|
|
|
|
|
|
|
public int getMaxEnumConstantsToAlignHorizontally() { |
|
return wrappedConfiguration.get(new DefaultConfigurationOption(ConfigOption.MAX_ENUM_CONSTANTS_TO_ALIGN_HORIZONTALLY)).get().asInteger(); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public PrettyPrinterConfiguration setMaxEnumConstantsToAlignHorizontally(int maxEnumConstantsToAlignHorizontally) { |
|
addOption(new DefaultConfigurationOption(ConfigOption.MAX_ENUM_CONSTANTS_TO_ALIGN_HORIZONTALLY, maxEnumConstantsToAlignHorizontally)); |
|
return this; |
|
} |
|
|
|
@Override |
|
public PrinterConfiguration addOption(ConfigurationOption option) { |
|
return wrappedConfiguration.addOption(option); |
|
} |
|
|
|
@Override |
|
public boolean isActivated(ConfigurationOption option) { |
|
return wrappedConfiguration.isActivated(option); |
|
} |
|
|
|
@Override |
|
public Optional<ConfigurationOption> get(ConfigurationOption option) { |
|
return wrappedConfiguration.get(option); |
|
} |
|
|
|
@Override |
|
public Set<ConfigurationOption> get() { |
|
return wrappedConfiguration.get(); |
|
} |
|
|
|
@Override |
|
public PrinterConfiguration removeOption(ConfigurationOption option) { |
|
return wrappedConfiguration.removeOption(option); |
|
} |
|
} |