Package com.diffplug.spotless.yaml
Class SerializeToByteArrayHack
java.lang.Object
com.diffplug.spotless.yaml.SerializeToByteArrayHack
- All Implemented Interfaces:
FormatterStep
,Serializable
,AutoCloseable
This step is a flag which marks that `ConfigurationCacheHackList` should
serialize each item individually into `byte[]` array, rather than using normal
serialization.
The reason to use this is if you are using `toggleOffOn` *and* two kinds of
google-java-format (e.g. one for format and the other for imports), then
problems with Java's handling of object graphs will cause your up-to-date checks
to always fail. `CombinedJavaFormatStepTest` recreates this situation. By adding
this step, it will trigger this workaround which fixes the up-to-dateness bug.
But, turning it on will break all `custom` steps that use Groovy closures. So
by default you get regular serialization. If you're using `toggleOffOn` and having
problems with up-to-dateness, then adding this step can be a workaround.
- See Also:
-
Constructor Details
-
SerializeToByteArrayHack
public SerializeToByteArrayHack()
-
-
Method Details
-
getName
Description copied from interface:FormatterStep
The name of the step, for debugging purposes.- Specified by:
getName
in interfaceFormatterStep
-
format
Description copied from interface:FormatterStep
Returns a formatted version of the given content.- Specified by:
format
in interfaceFormatterStep
- Parameters:
rawUnix
- the content to format, guaranteed to have unix-style newlines ('\n'); never nullfile
- the file whichrawUnix
was obtained from; never null. Pass the referenceFormatter.NO_FILE_SENTINEL
if and only if no file is actually associated withrawUnix
- Returns:
- the formatted content, guaranteed to only have unix-style newlines; may return null if the formatter step doesn't have any changes to make
- Throws:
Exception
- if the formatter step experiences a problem
-
close
- Specified by:
close
in interfaceAutoCloseable
- Throws:
Exception
-