Package com.diffplug.spotless
Interface FormatterFunc.Closeable
-
- All Superinterfaces:
AutoCloseable,FormatterFunc
- Enclosing interface:
- FormatterFunc
public static interface FormatterFunc.Closeable extends FormatterFunc, AutoCloseable
Function<String, String>andBiFunction<String, File, String>whose implementation requires a resource which should be released when the function is no longer needed.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceFormatterFunc.Closeable.ResourceFunc<T extends AutoCloseable>static interfaceFormatterFunc.Closeable.ResourceFuncNeedsFile<T extends AutoCloseable>-
Nested classes/interfaces inherited from interface com.diffplug.spotless.FormatterFunc
FormatterFunc.Closeable, FormatterFunc.NeedsFile
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description voidclose()static FormatterFunc.Closeableof(AutoCloseable closeable, FormatterFunc function)Deprecated.synonym forofDangerous(AutoCloseable, FormatterFunc)static <T extends AutoCloseable>
FormatterFunc.Closeableof(T resource, FormatterFunc.Closeable.ResourceFunc<T> function)Creates aFormatterFunc.Closeablewhich uses the given resource to execute the format function.static <T extends AutoCloseable>
FormatterFunc.Closeableof(T resource, FormatterFunc.Closeable.ResourceFuncNeedsFile<T> function)Creates aFormatterFunc.Closeablewhich uses the given resource to execute the file-dependent format function.static FormatterFunc.CloseableofDangerous(AutoCloseable closeable, FormatterFunc function)Dangerous way to create aFormatterFunc.Closeablefrom an AutoCloseable and a function.-
Methods inherited from interface com.diffplug.spotless.FormatterFunc
apply, apply
-
-
-
-
Method Detail
-
close
void close()
- Specified by:
closein interfaceAutoCloseable
-
ofDangerous
static FormatterFunc.Closeable ofDangerous(AutoCloseable closeable, FormatterFunc function)
Dangerous way to create aFormatterFunc.Closeablefrom an AutoCloseable and a function. It's important for FormatterStep's to allocate their resources as lazily as possible. It's easy to create a resource inside the state, and not realize that it may not be released. It's far better to use one of the non-deprecatedof()methods below. The bug (and its fix) which is easy to write using this method: https://github.com/diffplug/spotless/commit/7f16ecca031810b5e6e6f647e1f10a6d2152d9f4 How theof()methods below make the correct thing easier to write and safer: https://github.com/diffplug/spotless/commit/18c10f9c93d6f18f753233d0b5f028d5f0961916
-
of
@Deprecated static FormatterFunc.Closeable of(AutoCloseable closeable, FormatterFunc function)
Deprecated.synonym forofDangerous(AutoCloseable, FormatterFunc)
-
of
static <T extends AutoCloseable> FormatterFunc.Closeable of(T resource, FormatterFunc.Closeable.ResourceFunc<T> function)
Creates aFormatterFunc.Closeablewhich uses the given resource to execute the format function.
-
of
static <T extends AutoCloseable> FormatterFunc.Closeable of(T resource, FormatterFunc.Closeable.ResourceFuncNeedsFile<T> function)
Creates aFormatterFunc.Closeablewhich uses the given resource to execute the file-dependent format function.
-
-