LockKey { @Override public boolean equals(Object o) { if (o == this) { return true; } else if ((o != null) && o.getClass().equals(getClass())) { LockKey other = (LockKey) o; return new EqualsBuilder() .append(projectName, other.projectName) .append(branchName, other.branchName) .append(central, other.central) .isEquals(); } return false; } LockKey(String projectName, String branchName, boolean central); @Override boolean equals(Object o); @Override int hashCode();  }
@Test public void testEquals() { LockKey equal1 = new LockKey("p1", "b", true); LockKey equal2 = new LockKey("p1", "b", true); LockKey equal3 = new LockKey("p1", "b", true); LockKey different1 = new LockKey("p2", "b", true); LockKey different2 = new LockKey("p1", "b2", true); LockKey different3 = new LockKey("p1", "b", false); assertEqualsContract(equal1, equal2, equal3, different1); assertEqualsContract(equal1, equal2, equal3, different2); assertEqualsContract(equal1, equal2, equal3, different3); }