Package com.diffplug.spotless
Class PaddedCell
- java.lang.Object
-
- com.diffplug.spotless.PaddedCell
-
public final class PaddedCell extends Object
Models the result of applying aFormatteron a givenFilewhile characterizing various failure modes (slow convergence, cycles, and divergence). Seecheck(Formatter, File)as the entry point to this class.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPaddedCell.DirtyStateThe clean/dirty state of a single file.static classPaddedCell.TypeThe kind of result.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static PaddedCell.DirtyStatecalculateDirtyState(Formatter formatter, File file)Calculates whether the given file is dirty according to a PaddedCell invocation of the given formatter.static PaddedCell.DirtyStatecalculateDirtyState(Formatter formatter, File file, byte[] rawBytes)Stringcanonical()Returns the "canonical" form for this particular result (only possible if isResolvable).static PaddedCellcheck(Formatter formatter, File file)Applies the given formatter to the given file, checking that F(F(input)) == F(input).static PaddedCellcheck(Formatter formatter, File file, String originalUnix)Filefile()Returns the file which was tested.static PaddedCell.DirtyStateisClean()Returns the DirtyState which corresponds toisClean().booleanisResolvable()Any result which doesn't diverge can be resolved.booleanmisbehaved()Returns true iff the formatter misbehaved in any way (did not converge after a single iteration).List<String>steps()Returns the steps it takes to get to the result.PaddedCell.Typetype()Returns the type of the result (eitherPaddedCell.Type.CONVERGE,PaddedCell.Type.CYCLE, orPaddedCell.Type.DIVERGE).StringuserMessage()Returns a string which describes this result.
-
-
-
Method Detail
-
file
public 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).
-
check
public static PaddedCell check(Formatter formatter, 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, File file, 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 String canonical()
Returns the "canonical" form for this particular result (only possible if isResolvable).
-
userMessage
public String userMessage()
Returns a string which describes this result.
-
calculateDirtyState
public static PaddedCell.DirtyState calculateDirtyState(Formatter formatter, File file) throws 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:
IOException
-
calculateDirtyState
public static PaddedCell.DirtyState calculateDirtyState(Formatter formatter, File file, byte[] rawBytes) throws IOException
- Throws:
IOException
-
isClean
public static PaddedCell.DirtyState isClean()
Returns the DirtyState which corresponds toisClean().
-
-