Package com.diffplug.spotless
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 FormatterFuncAFunction<String, String>which can throw an exception. Technically, there is also aFileargument 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 interfaceFormatterFunc.CloseableFunction<String, String>andBiFunction<String, File, String>whose implementation requires a resource which should be released when the function is no longer needed.static interfaceFormatterFunc.NeedsFile
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description java.lang.Stringapply(java.lang.String input)default java.lang.Stringapply(java.lang.String unix, java.io.File file)static FormatterFuncneedsFile(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.NeedsFileto create aFormatterFuncwhich needs the File.
-
-