Class CommandLineOptions


  • final class CommandLineOptions
    extends java.lang.Object
    Command line options for google-java-format.

    google-java-format doesn't depend on AutoValue, to allow AutoValue to depend on google-java-format.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      (package private) static class  CommandLineOptions.Builder  
    • Constructor Summary

      Constructors 
      Constructor Description
      CommandLineOptions​(com.google.common.collect.ImmutableList<java.lang.String> files, boolean inPlace, com.google.common.collect.ImmutableRangeSet<java.lang.Integer> lines, com.google.common.collect.ImmutableList<java.lang.Integer> offsets, com.google.common.collect.ImmutableList<java.lang.Integer> lengths, boolean aosp, boolean version, boolean help, boolean stdin, boolean fixImportsOnly, boolean sortImports, boolean removeUnusedImports, boolean dryRun, boolean setExitIfChanged, java.util.Optional<java.lang.String> assumeFilename, boolean reflowLongStrings, boolean formatJavadoc)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) boolean aosp()
      Use AOSP style instead of Google Style (4-space indentation).
      (package private) java.util.Optional<java.lang.String> assumeFilename()
      Return the name to use for diagnostics when formatting standard input.
      (package private) static CommandLineOptions.Builder builder()  
      (package private) boolean dryRun()
      Print the paths of the files whose contents would change if the formatter were run normally.
      (package private) com.google.common.collect.ImmutableList<java.lang.String> files()
      The files to format.
      (package private) boolean fixImportsOnly()
      Fix imports, but do no formatting.
      (package private) boolean formatJavadoc()  
      (package private) boolean help()
      Print usage information.
      (package private) boolean inPlace()
      Format files in place.
      (package private) boolean isSelection()
      Returns true if partial formatting was selected.
      (package private) com.google.common.collect.ImmutableList<java.lang.Integer> lengths()
      Partial formatting region lengths, paired with offsets.
      (package private) com.google.common.collect.ImmutableRangeSet<java.lang.Integer> lines()
      Line ranges to format.
      (package private) com.google.common.collect.ImmutableList<java.lang.Integer> offsets()
      Character offsets for partial formatting, paired with lengths.
      (package private) boolean reflowLongStrings()  
      (package private) boolean removeUnusedImports()
      Remove unused imports.
      (package private) boolean setExitIfChanged()
      Return exit code 1 if there are any formatting changes.
      (package private) boolean sortImports()
      Sort imports.
      (package private) boolean stdin()
      Format input from stdin.
      (package private) boolean version()
      Print the version.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • files

        private final com.google.common.collect.ImmutableList<java.lang.String> files
      • inPlace

        private final boolean inPlace
      • lines

        private final com.google.common.collect.ImmutableRangeSet<java.lang.Integer> lines
      • offsets

        private final com.google.common.collect.ImmutableList<java.lang.Integer> offsets
      • lengths

        private final com.google.common.collect.ImmutableList<java.lang.Integer> lengths
      • aosp

        private final boolean aosp
      • version

        private final boolean version
      • help

        private final boolean help
      • stdin

        private final boolean stdin
      • fixImportsOnly

        private final boolean fixImportsOnly
      • sortImports

        private final boolean sortImports
      • removeUnusedImports

        private final boolean removeUnusedImports
      • dryRun

        private final boolean dryRun
      • setExitIfChanged

        private final boolean setExitIfChanged
      • assumeFilename

        private final java.util.Optional<java.lang.String> assumeFilename
      • reflowLongStrings

        private final boolean reflowLongStrings
      • formatJavadoc

        private final boolean formatJavadoc
    • Constructor Detail

      • CommandLineOptions

        CommandLineOptions​(com.google.common.collect.ImmutableList<java.lang.String> files,
                           boolean inPlace,
                           com.google.common.collect.ImmutableRangeSet<java.lang.Integer> lines,
                           com.google.common.collect.ImmutableList<java.lang.Integer> offsets,
                           com.google.common.collect.ImmutableList<java.lang.Integer> lengths,
                           boolean aosp,
                           boolean version,
                           boolean help,
                           boolean stdin,
                           boolean fixImportsOnly,
                           boolean sortImports,
                           boolean removeUnusedImports,
                           boolean dryRun,
                           boolean setExitIfChanged,
                           java.util.Optional<java.lang.String> assumeFilename,
                           boolean reflowLongStrings,
                           boolean formatJavadoc)
    • Method Detail

      • files

        com.google.common.collect.ImmutableList<java.lang.String> files()
        The files to format.
      • inPlace

        boolean inPlace()
        Format files in place.
      • lines

        com.google.common.collect.ImmutableRangeSet<java.lang.Integer> lines()
        Line ranges to format.
      • offsets

        com.google.common.collect.ImmutableList<java.lang.Integer> offsets()
        Character offsets for partial formatting, paired with lengths.
      • lengths

        com.google.common.collect.ImmutableList<java.lang.Integer> lengths()
        Partial formatting region lengths, paired with offsets.
      • aosp

        boolean aosp()
        Use AOSP style instead of Google Style (4-space indentation).
      • version

        boolean version()
        Print the version.
      • help

        boolean help()
        Print usage information.
      • stdin

        boolean stdin()
        Format input from stdin.
      • fixImportsOnly

        boolean fixImportsOnly()
        Fix imports, but do no formatting.
      • sortImports

        boolean sortImports()
        Sort imports.
      • removeUnusedImports

        boolean removeUnusedImports()
        Remove unused imports.
      • dryRun

        boolean dryRun()
        Print the paths of the files whose contents would change if the formatter were run normally.
      • setExitIfChanged

        boolean setExitIfChanged()
        Return exit code 1 if there are any formatting changes.
      • assumeFilename

        java.util.Optional<java.lang.String> assumeFilename()
        Return the name to use for diagnostics when formatting standard input.
      • reflowLongStrings

        boolean reflowLongStrings()
      • isSelection

        boolean isSelection()
        Returns true if partial formatting was selected.
      • formatJavadoc

        boolean formatJavadoc()