Package com.diffplug.spotless
Class PaddedCell
- java.lang.Object
-
- com.diffplug.spotless.PaddedCell
-
public final class PaddedCell extends java.lang.Object
Models the result of applying aFormatter
on a givenFile
while characterizing various failure modes (slow convergence, cycles, and divergence).See
check(Formatter, File)
as the entry point to this class.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PaddedCell.DirtyState
The clean/dirty state of a single file.static class
PaddedCell.Type
The kind of result.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static PaddedCell.DirtyState
calculateDirtyState(Formatter formatter, java.io.File file)
Calculates whether the given file is dirty according to a PaddedCell invocation of the given formatter.static PaddedCell.DirtyState
calculateDirtyState(Formatter formatter, java.io.File file, byte[] rawBytes)
java.lang.String
canonical()
Returns the "canonical" form for this particular result (only possible if isResolvable).static PaddedCell
check(Formatter formatter, java.io.File file)
Applies the given formatter to the given file, checking that F(F(input)) == F(input).static PaddedCell
check(Formatter formatter, java.io.File file, java.lang.String originalUnix)
java.io.File
file()
Returns the file which was tested.static PaddedCell.DirtyState
isClean()
Returns the DirtyState which corresponds toisClean()
.boolean
isResolvable()
Any result which doesn't diverge can be resolved.boolean
misbehaved()
Returns true iff the formatter misbehaved in any way (did not converge after a single iteration).java.util.List<java.lang.String>
steps()
Returns the steps it takes to get to the result.PaddedCell.Type
type()
Returns the type of the result (eitherPaddedCell.Type.CONVERGE
,PaddedCell.Type.CYCLE
, orPaddedCell.Type.DIVERGE
).java.lang.String
userMessage()
Returns a string which describes this result.
-
-
-
Method Detail
-
file
public java.io.File file()
Returns the file which was tested.
-
type
public PaddedCell.Type type()
Returns the type of the result (eitherPaddedCell.Type.CONVERGE
,PaddedCell.Type.CYCLE
, orPaddedCell.Type.DIVERGE
).
-
steps
public java.util.List<java.lang.String> steps()
Returns the steps it takes to get to the result.
-
check
public static PaddedCell check(Formatter formatter, java.io.File file)
Applies the given formatter to the given file, checking that F(F(input)) == F(input).If it meets this test,
misbehaved()
will return false.If it fails the test,
misbehaved()
will return true, and you can find out more about the misbehavior based on itsPaddedCell.Type
.
-
check
public static PaddedCell check(Formatter formatter, java.io.File file, java.lang.String originalUnix)
-
misbehaved
public boolean misbehaved()
Returns true iff the formatter misbehaved in any way (did not converge after a single iteration).
-
isResolvable
public boolean isResolvable()
Any result which doesn't diverge can be resolved.
-
canonical
public java.lang.String canonical()
Returns the "canonical" form for this particular result (only possible if isResolvable).
-
userMessage
public java.lang.String userMessage()
Returns a string which describes this result.
-
calculateDirtyState
public static PaddedCell.DirtyState calculateDirtyState(Formatter formatter, java.io.File file) throws java.io.IOException
Calculates whether the given file is dirty according to a PaddedCell invocation of the given formatter. DirtyState includes the clean state of the file, as well as a warning if we were not able to apply the formatter due to diverging idempotence.- Throws:
java.io.IOException
-
calculateDirtyState
public static PaddedCell.DirtyState calculateDirtyState(Formatter formatter, java.io.File file, byte[] rawBytes) throws java.io.IOException
- Throws:
java.io.IOException
-
isClean
public static PaddedCell.DirtyState isClean()
Returns the DirtyState which corresponds toisClean()
.
-
-