@Test public void testEquals() { final Severity severity = Severity.MINOR; final PackageId packId = PackageId.fromString("my_pack"); final String description = "some description"; final Violation violation = new Violation() { @Override public Severity getSeverity() { return severity; } @Override public Collection<PackageId> getPackages() { return Collections.singletonList(packId); } @Override public String getDescription() { return description; } }; final JsonObject json = violation.toJson(); final SimpleViolation simpleViolation = SimpleViolation.fromJson(json); assertNotEquals("SimpleViolation not equal to Violation", simpleViolation, violation); final SimpleViolation simpleViolationCopy = SimpleViolation.fromReported(violation); assertEquals("SimpleViolation equal to copy SimpleViolation", simpleViolation, simpleViolationCopy); assertNotEquals("SimpleViolation hashCode not equal to Violation hashCode", simpleViolation.hashCode(), violation.hashCode()); assertEquals("SimpleViolation hashCode equal to copy SimpleViolation hashCode", simpleViolation.hashCode(), simpleViolationCopy.hashCode()); }
@Override public boolean equals(final Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; SimpleViolation that = (SimpleViolation) o; return severity == that.severity && Objects.equals(description, that.description) && packages.equals(that.packages); }
SimpleViolation implements Violation { @Override public boolean equals(final Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; SimpleViolation that = (SimpleViolation) o; return severity == that.severity && Objects.equals(description, that.description) && packages.equals(that.packages); } }
SimpleViolation implements Violation { @Override public boolean equals(final Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; SimpleViolation that = (SimpleViolation) o; return severity == that.severity && Objects.equals(description, that.description) && packages.equals(that.packages); } SimpleViolation(final Severity severity, final String description, final PackageId... packages);  SimpleViolation(final Severity severity, final String description, final List<PackageId> packages); }
SimpleViolation implements Violation { @Override public boolean equals(final Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; SimpleViolation that = (SimpleViolation) o; return severity == that.severity && Objects.equals(description, that.description) && packages.equals(that.packages); } SimpleViolation(final Severity severity, final String description, final PackageId... packages);  SimpleViolation(final Severity severity, final String description, final List<PackageId> packages); static Builder builder(); static Builder builder(final ResourceBundle resourceBundle); @Override Severity getSeverity(); @Override Collection<PackageId> getPackages(); @Override String getDescription(); static SimpleViolation fromReported(final Violation violation); static SimpleViolation fromJson(final JsonObject jsonViolation); @Override String toString(); @Override boolean equals(final Object o); @Override int hashCode(); }
SimpleViolation implements Violation { @Override public boolean equals(final Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; SimpleViolation that = (SimpleViolation) o; return severity == that.severity && Objects.equals(description, that.description) && packages.equals(that.packages); } SimpleViolation(final Severity severity, final String description, final PackageId... packages);  SimpleViolation(final Severity severity, final String description, final List<PackageId> packages); static Builder builder(); static Builder builder(final ResourceBundle resourceBundle); @Override Severity getSeverity(); @Override Collection<PackageId> getPackages(); @Override String getDescription(); static SimpleViolation fromReported(final Violation violation); static SimpleViolation fromJson(final JsonObject jsonViolation); @Override String toString(); @Override boolean equals(final Object o); @Override int hashCode();  }