RectangularBox { @Override public boolean equals(Object other) { if (this == other) { return true; } if (!(other instanceof RectangularBox)) { return false; } RectangularBox instance = (RectangularBox) other; return new EqualsBuilder().append(top, instance.getTop()).append(right, instance.getRight()) .append(left, instance.getLeft()).append(bottom, instance.getBottom()).isEquals(); } RectangularBox(int bottom, int left, int top, int right); int getBottom(); int getLeft(); int getTop(); int getRight(); void rotate(Rotation desiredRotation); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object other); static RectangularBox newInstance(int bottom, int left, int top, int right); static RectangularBox newInstanceFromPoints(Point bottomLeft, Point topRight); TopLeftRectangularBox toTopLeftRectangularBox();  }
@Test public void testEquals() { RectangularBox eq1 = RectangularBox.newInstance(0, 1, 10, 9); RectangularBox eq2 = RectangularBox.newInstanceFromPoints(new Point(1, 0), new Point(9, 10)); RectangularBox eq3 = RectangularBox.newInstance(0, 1, 10, 9); RectangularBox diff = RectangularBox.newInstance(0, 2, 10, 9); TestUtils.testEqualsAndHashCodes(eq1, eq2, eq3, diff); }