br.com.anteros.nosql.persistence.mongodb.geo.Point Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of Anteros-NoSql-Persistence-MongoDB Show documentation
Show all versions of Anteros-NoSql-Persistence-MongoDB Show documentation
Anteros NoSQL Persistence MongoDB.
package br.com.anteros.nosql.persistence.mongodb.geo;
import java.util.ArrayList;
import java.util.List;
import br.com.anteros.nosql.persistence.metadata.annotations.Embedded;
@Embedded
public class Point implements Geometry {
private final List coordinates = new ArrayList();
Point(final double latitude, final double longitude) {
coordinates.add(longitude);
coordinates.add(latitude);
}
Point(final List coordinates) {
this.coordinates.addAll(coordinates);
}
@Override
public List getCoordinates() {
return coordinates;
}
public double getLatitude() {
return coordinates.get(1);
}
public double getLongitude() {
return coordinates.get(0);
}
@Override
public int hashCode() {
return coordinates.hashCode();
}
@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Point point = (Point) o;
if (getCoordinates().size() != point.getCoordinates().size()) {
return false;
}
for (int i = 0; i < coordinates.size(); i++) {
final Double coordinate = coordinates.get(i);
if (Double.compare(coordinate, point.getCoordinates().get(i)) != 0) {
return false;
}
}
return true;
}
@Override
public String toString() {
return String.format("Point{coordinates=%s}", coordinates);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy