/** * Compares the specified object with this envelope for equality. If the given object is not * an instance of {@code Envelope2D}, then the two objects are compared as plain rectangles, * i.e. the {@linkplain #getCoordinateReferenceSystem() coordinate reference system} of this * envelope is ignored. * * <div class="section">Note on {@code hashCode()}</div> * This class does not override the {@link #hashCode()} method for consistency with the * {@link Rectangle2D#equals(Object)} method, which compare arbitrary {@code Rectangle2D} * implementations. * * @param object the object to compare with this envelope. * @return {@code true} if the given object is equal to this envelope. */ @Override public boolean equals(final Object object) { if (object instanceof Envelope2D) { final Envelope2D other = (Envelope2D) object; return doubleToLongBits(x) == doubleToLongBits(other.x) && doubleToLongBits(y) == doubleToLongBits(other.y) && doubleToLongBits(width) == doubleToLongBits(other.width) && doubleToLongBits(height) == doubleToLongBits(other.height) && Objects.equals(crs, other.crs); } else { return super.equals(object); } }
/** * Compares the specified object with this envelope for equality. If the given object is not * an instance of {@code Envelope2D}, then the two objects are compared as plain rectangles, * i.e. the {@linkplain #getCoordinateReferenceSystem() coordinate reference system} of this * envelope is ignored. * * <div class="section">Note on {@code hashCode()}</div> * This class does not override the {@link #hashCode()} method for consistency with the * {@link Rectangle2D#equals(Object)} method, which compare arbitrary {@code Rectangle2D} * implementations. * * @param object the object to compare with this envelope. * @return {@code true} if the given object is equal to this envelope. */ @Override public boolean equals(final Object object) { if (object instanceof Envelope2D) { final Envelope2D other = (Envelope2D) object; return doubleToLongBits(x) == doubleToLongBits(other.x) && doubleToLongBits(y) == doubleToLongBits(other.y) && doubleToLongBits(width) == doubleToLongBits(other.width) && doubleToLongBits(height) == doubleToLongBits(other.height) && Objects.equals(crs, other.crs); } else { return super.equals(object); } }
/** * Compares the specified object with this envelope for equality. * * @param object The object to compare with this envelope. * @return {@code true} if the given object is equals to this envelope. */ @Override public boolean equals(final Object object) { if (super.equals(object)) { final CoordinateReferenceSystem otherCRS = (object instanceof Envelope2D) ? ((Envelope2D) object).crs : null; return Utilities.equals(crs, otherCRS); } return false; }