public interface FormatterStep
extends java.io.Serializable
An implementation of this class specifies a single step in a formatting process.
The input is guaranteed to have unix-style newlines, and the output is required to not introduce any windows-style newlines as well.
| Modifier and Type | Interface and Description |
|---|---|
static class |
FormatterStep.Strict<State extends java.io.Serializable>
Implements a FormatterStep in a strict way which guarantees correct and lazy implementation
of up-to-date checks.
|
| Modifier and Type | Method and Description |
|---|---|
static <State extends java.io.Serializable> |
create(java.lang.String name,
State state,
ThrowingEx.Function<State,FormatterFunc> stateToFormatter) |
static <State extends java.io.Serializable> |
createLazy(java.lang.String name,
ThrowingEx.Supplier<State> stateSupplier,
ThrowingEx.Function<State,FormatterFunc> stateToFormatter) |
static FormatterStep |
createNeverUpToDate(java.lang.String name,
FormatterFunc function) |
static FormatterStep |
createNeverUpToDateLazy(java.lang.String name,
ThrowingEx.Supplier<FormatterFunc> functionSupplier) |
default FormatterStep |
filterByFile(SerializableFileFilter filter)
Returns a new FormatterStep which will only apply its changes
to files which pass the given filter.
|
java.lang.String |
format(java.lang.String rawUnix,
java.io.File file)
Returns a formatted version of the given content.
|
java.lang.String |
getName()
The name of the step, for debugging purposes.
|
java.lang.String getName()
The name of the step, for debugging purposes.
@Nullable
java.lang.String format(java.lang.String rawUnix,
java.io.File file)
throws java.lang.Throwable
Returns a formatted version of the given content.
rawUnix - the content to format, guaranteed to have unix-style newlines (‘\n’); never nullfile - the file which rawUnix was obtained from; never null. Pass an empty file using
new File("") if and only if no file is actually associated with rawUnixjava.lang.Exception - if the formatter step experiences a problemjava.lang.Throwabledefault FormatterStep filterByFile(SerializableFileFilter filter)
Returns a new FormatterStep which will only apply its changes to files which pass the given filter.
The provided filter must be serializable.
static <State extends java.io.Serializable> FormatterStep createLazy(java.lang.String name, ThrowingEx.Supplier<State> stateSupplier, ThrowingEx.Function<State,FormatterFunc> stateToFormatter)
name - The name of the formatter stepstateSupplier - If the rule has any state, this supplier will calculate it lazily, and the result
will be passed to stateToFormatterstateToFormatter - A pure function which generates a formatting function using
only the state supplied by state and nowhere else.static <State extends java.io.Serializable> FormatterStep create(java.lang.String name, State state, ThrowingEx.Function<State,FormatterFunc> stateToFormatter)
name - The name of the formatter stepstate - If the rule has any state, this state must contain all of itstateToFormatter - A pure function which generates a formatting function using
only the state supplied by state and nowhere else.static FormatterStep createNeverUpToDateLazy(java.lang.String name, ThrowingEx.Supplier<FormatterFunc> functionSupplier)
name - The name of the formatter stepfunctionSupplier - A supplier which will lazily generate the function
used by the formatter stepstatic FormatterStep createNeverUpToDate(java.lang.String name, FormatterFunc function)
name - The name of the formatter stepfunction - The function used by the formatter step