Interface FormatterFunc

  • All Known Subinterfaces:
    FormatterFunc.Closeable, FormatterFunc.NeedsFile
    Functional Interface:
    This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

    @FunctionalInterface
    public interface FormatterFunc
    A Function<String, String> which can throw an exception. Technically, there is also a File argument which gets passed around as well, but that is invisible to formatters. If you need the File, see FormatterFunc.NeedsFile.
    • Method Detail

      • apply

        java.lang.String apply​(java.lang.String input)
                        throws java.lang.Exception
        Throws:
        java.lang.Exception
      • apply

        default java.lang.String apply​(java.lang.String unix,
                                       java.io.File file)
                                throws java.lang.Exception
        Throws:
        java.lang.Exception
      • needsFile

        static FormatterFunc needsFile​(FormatterFunc.NeedsFile needsFile)
        Ideally, formatters don't need the underlying file. But in case they do, they should only use it's path, and should never read the content inside the file, because that breaks the Function<String, String> composition that Spotless is based on. For the rare case that you need access to the file, use this method or FormatterFunc.NeedsFile to create a FormatterFunc which needs the File.