@Test public void equalsTest() { Rectangle rectangle1 = create(1, 2, 3, 4); Rectangle rectangle2 = create(1, 2, 3, 4); Rectangle rectangle3 = create(3, 2, 3, 4); Rectangle rectangle4 = create(1, 4, 3, 4); Rectangle rectangle5 = create(1, 2, 1, 4); Rectangle rectangle6 = create(1, 2, 3, 2); TestUtils.equalsTest(rectangle1, rectangle2); TestUtils.notEqualsTest(rectangle1, rectangle3); TestUtils.notEqualsTest(rectangle1, rectangle4); TestUtils.notEqualsTest(rectangle1, rectangle5); TestUtils.notEqualsTest(rectangle1, rectangle6); TestUtils.notEqualsTest(rectangle1, new Object()); TestUtils.notEqualsTest(rectangle1, null); }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } else if (!(obj instanceof Rectangle)) { return false; } Rectangle other = (Rectangle) obj; if (Double.doubleToLongBits(this.left) != Double.doubleToLongBits(other.left)) { return false; } else if (Double.doubleToLongBits(this.top) != Double.doubleToLongBits(other.top)) { return false; } else if (Double.doubleToLongBits(this.right) != Double.doubleToLongBits(other.right)) { return false; } else if (Double.doubleToLongBits(this.bottom) != Double.doubleToLongBits(other.bottom)) { return false; } return true; }
Rectangle implements Serializable { @Override public boolean equals(Object obj) { if (this == obj) { return true; } else if (!(obj instanceof Rectangle)) { return false; } Rectangle other = (Rectangle) obj; if (Double.doubleToLongBits(this.left) != Double.doubleToLongBits(other.left)) { return false; } else if (Double.doubleToLongBits(this.top) != Double.doubleToLongBits(other.top)) { return false; } else if (Double.doubleToLongBits(this.right) != Double.doubleToLongBits(other.right)) { return false; } else if (Double.doubleToLongBits(this.bottom) != Double.doubleToLongBits(other.bottom)) { return false; } return true; } }
Rectangle implements Serializable { @Override public boolean equals(Object obj) { if (this == obj) { return true; } else if (!(obj instanceof Rectangle)) { return false; } Rectangle other = (Rectangle) obj; if (Double.doubleToLongBits(this.left) != Double.doubleToLongBits(other.left)) { return false; } else if (Double.doubleToLongBits(this.top) != Double.doubleToLongBits(other.top)) { return false; } else if (Double.doubleToLongBits(this.right) != Double.doubleToLongBits(other.right)) { return false; } else if (Double.doubleToLongBits(this.bottom) != Double.doubleToLongBits(other.bottom)) { return false; } return true; } Rectangle(double left, double top, double right, double bottom); }
Rectangle implements Serializable { @Override public boolean equals(Object obj) { if (this == obj) { return true; } else if (!(obj instanceof Rectangle)) { return false; } Rectangle other = (Rectangle) obj; if (Double.doubleToLongBits(this.left) != Double.doubleToLongBits(other.left)) { return false; } else if (Double.doubleToLongBits(this.top) != Double.doubleToLongBits(other.top)) { return false; } else if (Double.doubleToLongBits(this.right) != Double.doubleToLongBits(other.right)) { return false; } else if (Double.doubleToLongBits(this.bottom) != Double.doubleToLongBits(other.bottom)) { return false; } return true; } Rectangle(double left, double top, double right, double bottom); boolean contains(Point point); @Override boolean equals(Object obj); Point getCenter(); double getCenterX(); double getCenterY(); double getHeight(); double getWidth(); @Override int hashCode(); boolean intersects(Rectangle rectangle); boolean intersectsCircle(double pointX, double pointY, double radius); @Override String toString(); }
Rectangle implements Serializable { @Override public boolean equals(Object obj) { if (this == obj) { return true; } else if (!(obj instanceof Rectangle)) { return false; } Rectangle other = (Rectangle) obj; if (Double.doubleToLongBits(this.left) != Double.doubleToLongBits(other.left)) { return false; } else if (Double.doubleToLongBits(this.top) != Double.doubleToLongBits(other.top)) { return false; } else if (Double.doubleToLongBits(this.right) != Double.doubleToLongBits(other.right)) { return false; } else if (Double.doubleToLongBits(this.bottom) != Double.doubleToLongBits(other.bottom)) { return false; } return true; } Rectangle(double left, double top, double right, double bottom); boolean contains(Point point); @Override boolean equals(Object obj); Point getCenter(); double getCenterX(); double getCenterY(); double getHeight(); double getWidth(); @Override int hashCode(); boolean intersects(Rectangle rectangle); boolean intersectsCircle(double pointX, double pointY, double radius); @Override String toString(); final double bottom; final double left; final double right; final double top; }