com.what3words.javawrapper.request.BoundingBox Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of w3w-java-wrapper Show documentation
Show all versions of w3w-java-wrapper Show documentation
Java library for what3words REST API.
package com.what3words.javawrapper.request;
/**
* This class defines a BoundingBox
which which represents a range of latitudes and longitudes.
*/
public final class BoundingBox {
public final Coordinates sw;
public final Coordinates ne;
/**
* Creates a new instance of a BoundingBox
.
* @param sw the coordinates of the southwest corner
* @param ne the coordinates of the northeast corner
*/
public BoundingBox(Coordinates sw, Coordinates ne) {
this.sw = sw;
this.ne = ne;
}
/**
* Compares this BoundingBox
to the specified object. The result is true if and only if
* the argument is not null
and is a BoundingBox
object that represents the
* same southwest and northeast coordinates as this object.
* @return true
if the given object represents a BoundingBox
equivalent to this
* BoundingBox
, false otherwise
*/
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
BoundingBox that = (BoundingBox) o;
return (sw != null ? sw.equals(that.sw) : that.sw == null) &&
(ne != null ? ne.equals(that.ne) : that.ne == null);
}
/**
* Returns a hash code for this BoundingBox
.
*/
@Override
public int hashCode() {
int result = sw != null ? sw.hashCode() : 0;
result = 31 * result + (ne != null ? ne.hashCode() : 0);
return result;
}
/**
* Returns a String object representing this BoundingBox
.
*/
@Override
public String toString() {
return "BoundingBox{" +
"sw=" + sw +
", ne=" + ne +
'}';
}
}