public final class Formatter extends Object implements Serializable, AutoCloseable
Formatter which performs the full formatting.
| Modifier and Type | Class and Description |
|---|---|
static class |
Formatter.Builder |
| Modifier and Type | Method and Description |
|---|---|
void |
applyTo(File file)
Applies formatting to the given file.
|
String |
applyToAndReturnResultIfDirty(File file)
Applies formatting to the given file.
|
static Formatter.Builder |
builder() |
void |
close() |
String |
compute(String unix,
File file)
Returns the result of calling all of the FormatterSteps.
|
String |
computeLineEndings(String unix,
File file)
Applies the appropriate line endings to the given unix content.
|
boolean |
equals(Object obj) |
Charset |
getEncoding() |
FormatExceptionPolicy |
getExceptionPolicy() |
LineEnding.Policy |
getLineEndingsPolicy() |
Path |
getRootDir() |
List<FormatterStep> |
getSteps() |
int |
hashCode() |
boolean |
isClean(File file)
Returns true iff the given file’s formatting is up-to-date.
|
public LineEnding.Policy getLineEndingsPolicy()
public Charset getEncoding()
public Path getRootDir()
public List<FormatterStep> getSteps()
public FormatExceptionPolicy getExceptionPolicy()
public static Formatter.Builder builder()
public boolean isClean(File file) throws IOException
Returns true iff the given file’s formatting is up-to-date.
IOExceptionpublic void applyTo(File file) throws IOException
Applies formatting to the given file.
IOException@Nullable public String applyToAndReturnResultIfDirty(File file) throws IOException
Applies formatting to the given file.
Returns null if the file was already clean, or the formatted result with unix newlines if it was not.
IOExceptionpublic String computeLineEndings(String unix, File file)
Applies the appropriate line endings to the given unix content.
public String compute(String unix, File file)
Returns the result of calling all of the FormatterSteps. The input must have unix line endings, and the output is guaranteed to also have unix line endings.
public void close()
close in interface AutoCloseable