Package com.diffplug.spotless
Class Formatter
- java.lang.Object
-
- com.diffplug.spotless.Formatter
-
- All Implemented Interfaces:
Serializable,AutoCloseable
public final class Formatter extends Object implements Serializable, AutoCloseable
Formatter which performs the full formatting.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classFormatter.Builder
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidapplyTo(File file)Applies formatting to the given file.StringapplyToAndReturnResultIfDirty(File file)Applies formatting to the given file.static Formatter.Builderbuilder()voidclose()Stringcompute(String unix, File file)Returns the result of calling all of the FormatterSteps.StringcomputeLineEndings(String unix, File file)Applies the appropriate line endings to the given unix content.booleanequals(Object obj)CharsetgetEncoding()FormatExceptionPolicygetExceptionPolicy()LineEnding.PolicygetLineEndingsPolicy()PathgetRootDir()List<FormatterStep>getSteps()inthashCode()booleanisClean(File file)Returns true iff the given file's formatting is up-to-date.
-
-
-
Method Detail
-
getLineEndingsPolicy
public LineEnding.Policy getLineEndingsPolicy()
-
getEncoding
public Charset getEncoding()
-
getRootDir
public Path getRootDir()
-
getSteps
public List<FormatterStep> getSteps()
-
getExceptionPolicy
public FormatExceptionPolicy getExceptionPolicy()
-
builder
public static Formatter.Builder builder()
-
isClean
public boolean isClean(File file) throws IOException
Returns true iff the given file's formatting is up-to-date.- Throws:
IOException
-
applyTo
public void applyTo(File file) throws IOException
Applies formatting to the given file.- Throws:
IOException
-
applyToAndReturnResultIfDirty
@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.- Throws:
IOException
-
computeLineEndings
public String computeLineEndings(String unix, File file)
Applies the appropriate line endings to the given unix content.
-
compute
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.
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable
-
-