All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.what3words.javawrapper.request.BoundingBox Maven / Gradle / Ivy

There is a newer version: 3.1.21
Show newest version
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 +
                '}';
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy