Package com.diffplug.spotless
Interface FormatterFunc
-
- All Known Subinterfaces:
FormatterFunc.Closeable
,FormatterFunc.NeedsFile
- All Known Implementing Classes:
RdfFormatterFunc
- 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
AFunction<String, String>
which can throw an exception. Technically, there is also aFile
argument which gets passed around as well, but that is invisible to formatters. If you need the File, seeFormatterFunc.NeedsFile
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
FormatterFunc.Closeable
Function<String, String>
andBiFunction<String, File, String>
whose implementation requires a resource which should be released when the function is no longer needed.static interface
FormatterFunc.NeedsFile
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description java.lang.String
apply(java.lang.String input)
default java.lang.String
apply(java.lang.String unix, java.io.File file)
static FormatterFunc
needsFile(FormatterFunc.NeedsFile needsFile)
Ideally, formatters don't need the underlying file.
-
-
-
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 theFunction<String, String>
composition that Spotless is based on. For the rare case that you need access to the file, use this method orFormatterFunc.NeedsFile
to create aFormatterFunc
which needs the File.
-
-