package io.vertx.pgclient.data;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
public class Polygon {
private List<Point> points;
public Polygon() {
this(new ArrayList<>());
}
public Polygon(List<Point> points) {
this.points = points;
}
public List<Point> getPoints() {
return points;
}
public void setPoints(List<Point> points) {
this.points = points;
}
public Polygon addPoint(Point point) {
Objects.requireNonNull(point);
if (points == null) {
points = new ArrayList<>();
}
points.add(point);
return this;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Polygon polygon = (Polygon) o;
return points.equals(polygon.points);
}
@Override
public int hashCode() {
return points.hashCode();
}
@Override
public String toString() {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("Polygon");
stringBuilder.append("(");
for (int i = 0; i < points.size(); i++) {
Point point = points.get(i);
stringBuilder.append(point.toString());
if (i != points.size() - 1) {
stringBuilder.append(",");
}
}
stringBuilder.append(")");
return stringBuilder.toString();
}
}