Formatter implements Serializable, AutoCloseable { public static Formatter.Builder builder() { return new Formatter.Builder(); } private  Formatter(LineEnding.Policy lineEndingsPolicy, Charset encoding, Path rootDirectory, List<FormatterStep> steps, FormatExceptionPolicy exceptionPolicy); LineEnding.Policy getLineEndingsPolicy(); Charset getEncoding(); Path getRootDir(); List<FormatterStep> getSteps(); FormatExceptionPolicy getExceptionPolicy(); static Formatter.Builder builder(); boolean isClean(File file); void applyTo(File file); @Nullable String applyToAndReturnResultIfDirty(File file); String computeLineEndings(String unix, File file); String compute(String unix, File file); @Override int hashCode(); @Override boolean equals(Object obj); @SuppressWarnings("rawtypes") @Override void close();  }
@Test public void equality() { new SerializableEqualityTester() { private LineEnding.Policy lineEndingsPolicy = LineEnding.UNIX.createPolicy(); private Charset encoding = StandardCharsets.UTF_8; private Path rootDir = Paths.get(StandardSystemProperty.USER_DIR.value()); private List<FormatterStep> steps = new ArrayList<>(); private FormatExceptionPolicy exceptionPolicy = FormatExceptionPolicy.failOnlyOnError(); @Override protected void setupTest(API api) throws Exception { api.areDifferentThan(); lineEndingsPolicy = LineEnding.WINDOWS.createPolicy(); api.areDifferentThan(); encoding = StandardCharsets.UTF_16; api.areDifferentThan(); rootDir = rootDir.getParent(); api.areDifferentThan(); steps.add(EndWithNewlineStep.create()); api.areDifferentThan(); { FormatExceptionPolicyStrict standard = new FormatExceptionPolicyStrict(); standard.excludePath("path"); exceptionPolicy = standard; api.areDifferentThan(); } { FormatExceptionPolicyStrict standard = new FormatExceptionPolicyStrict(); standard.excludeStep("step"); exceptionPolicy = standard; api.areDifferentThan(); } } @Override protected Formatter create() { return Formatter.builder() .lineEndingsPolicy(lineEndingsPolicy) .encoding(encoding) .rootDir(rootDir) .steps(steps) .exceptionPolicy(exceptionPolicy) .build(); } }.testEquals(); }