@Test public void testEquals() { Query f0 = new Query(); assertFalse(f0.equals(null)); assertFalse(f0.equals(new Product())); Query f1 = new Query(); f1.setManufacturer("Alice"); Query f1Duplicate = new Query(); f1Duplicate.setManufacturer("Alice"); Query f1NotDuplicate = new Query(); f1NotDuplicate.setComponent("Bob"); Query f2 = new Query(); f2.setManufacturer("Alice"); f2.setComponent("Bob"); Query f2Duplicate = new Query(); f2Duplicate.setManufacturer("Alice"); f2Duplicate.setComponent("Bob"); Query f2DuplicateLocked = new Query(); f2Duplicate.setManufacturer("Alice"); f2Duplicate.setComponent("Bob"); f2DuplicateLocked.lock(); assertNotNull(f0); assertEquals(f0, new Query()); assertEquals(f1, f1Duplicate); assertEquals(f2, f2Duplicate); assertFalse(f1.equals(f2)); assertTrue(f1.equals(f1)); assertFalse(f1.equals(null)); assertFalse(f1.equals(new Object())); assertEquals(f0.hashCode(), new Query().hashCode()); assertEquals(f1.hashCode(), f1Duplicate.hashCode()); assertFalse(f1.hashCode() == f1NotDuplicate.hashCode()); assertFalse(f2.equals(f2DuplicateLocked)); assertFalse(f1.equals(f1NotDuplicate)); assertFalse(f1NotDuplicate.equals(f2)); assertFalse(f1NotDuplicate.equals(f1)); assertFalse(f1NotDuplicate.equals(f0)); assertFalse(f0.equals(f1)); assertFalse(f0.equals(f1NotDuplicate)); assertFalse(f2.equals(f1)); assertFalse(f2.equals(f1NotDuplicate)); assertFalse(f2DuplicateLocked.hashCode() == f2.hashCode()); }
@Override public int hashCode() { return query.hashCode(); }
/** * Get the hashCode for this object overrides Object.hashCode() * * @return the hashCode */ @Override public int hashCode() { return subquery.hashCode() + 3 * op.hashCode(); }
/** * Overrides Object.hashCode(). * * @return an arbitrary integer based on the contents of the Constraint */ @Override public int hashCode() { return (3 * left.hashCode()) + (5 * right.hashCode()); }