Package com.diffplug.spotless
Interface FormatterFunc.Closeable
-
- All Superinterfaces:
java.lang.AutoCloseable
,FormatterFunc
- Enclosing interface:
- FormatterFunc
public static interface FormatterFunc.Closeable extends FormatterFunc, java.lang.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 interface
FormatterFunc.Closeable.ResourceFunc<T extends java.lang.AutoCloseable>
static interface
FormatterFunc.Closeable.ResourceFuncNeedsFile<T extends java.lang.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 void
close()
static FormatterFunc.Closeable
of(java.lang.AutoCloseable closeable, FormatterFunc function)
Deprecated.synonym forofDangerous(AutoCloseable, FormatterFunc)
static <T extends java.lang.AutoCloseable>
FormatterFunc.Closeableof(T resource, FormatterFunc.Closeable.ResourceFunc<T> function)
Creates aFormatterFunc.Closeable
which uses the given resource to execute the format function.static <T extends java.lang.AutoCloseable>
FormatterFunc.Closeableof(T resource, FormatterFunc.Closeable.ResourceFuncNeedsFile<T> function)
Creates aFormatterFunc.Closeable
which uses the given resource to execute the file-dependent format function.static FormatterFunc.Closeable
ofDangerous(java.lang.AutoCloseable closeable, FormatterFunc function)
Dangerous way to create aFormatterFunc.Closeable
from an AutoCloseable and a function.-
Methods inherited from interface com.diffplug.spotless.FormatterFunc
apply, apply
-
-
-
-
Method Detail
-
close
void close()
- Specified by:
close
in interfacejava.lang.AutoCloseable
-
ofDangerous
static FormatterFunc.Closeable ofDangerous(java.lang.AutoCloseable closeable, FormatterFunc function)
Dangerous way to create aFormatterFunc.Closeable
from 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(java.lang.AutoCloseable closeable, FormatterFunc function)
Deprecated.synonym forofDangerous(AutoCloseable, FormatterFunc)
-
of
static <T extends java.lang.AutoCloseable> FormatterFunc.Closeable of(T resource, FormatterFunc.Closeable.ResourceFunc<T> function)
Creates aFormatterFunc.Closeable
which uses the given resource to execute the format function.
-
of
static <T extends java.lang.AutoCloseable> FormatterFunc.Closeable of(T resource, FormatterFunc.Closeable.ResourceFuncNeedsFile<T> function)
Creates aFormatterFunc.Closeable
which uses the given resource to execute the file-dependent format function.
-
-