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 class
Formatter.Builder
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method 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.
-
-
-
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:
close
in interfaceAutoCloseable
-
-