public interface FormatterStep extends 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 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 Serializable> |
create(String name,
State state,
ThrowingEx.Function<State,FormatterFunc> stateToFormatter) |
static <State extends Serializable> |
createLazy(String name,
ThrowingEx.Supplier<State> stateSupplier,
ThrowingEx.Function<State,FormatterFunc> stateToFormatter) |
static FormatterStep |
createNeverUpToDate(String name,
FormatterFunc function) |
static FormatterStep |
createNeverUpToDateLazy(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.
|
String |
format(String rawUnix,
File file)
Returns a formatted version of the given content.
|
String |
getName()
The name of the step, for debugging purposes.
|
String getName()
The name of the step, for debugging purposes.
@Nullable String format(String rawUnix, File file) throws Exception
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 rawUnixException - if the formatter step experiences a problemdefault 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 Serializable> FormatterStep createLazy(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 Serializable> FormatterStep create(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(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(String name, FormatterFunc function)
name - The name of the formatter stepfunction - The function used by the formatter step