Class Formatter

    • Field Detail

      • NO_FILE_SENTINEL

        public static final File NO_FILE_SENTINEL
        This Sentinel reference may be used to pass string content to a Formatter or FormatterStep when there is no actual File to format
    • Method Detail

      • getName

        public String getName()
      • getEncoding

        public Charset getEncoding()
      • getRootDir

        public Path getRootDir()
      • isClean

        public boolean isClean​(File file)
                        throws IOException
        Returns true iff the given file's formatting is up-to-date.
        Throws:
        IOException
      • applyToAndReturnResultIfDirty

        @Nullable
        public String applyToAndReturnResultIfDirty​(File file)
                                             throws IOException
        Applies formatting to the given file. Returns null if the file was already clean, or the formatted result with unix newlines if it was not.
        Throws:
        IOException
      • computeLineEndings

        public String computeLineEndings​(String unix,
                                         File file)
        Applies the appropriate line endings to the given unix content.
      • compute

        public String compute​(String unix,
                              File file)
        Returns the result of calling all of the FormatterSteps. The input must have unix line endings, and the output is guaranteed to also have unix line endings.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object