package io.vertx.pgclient.data;
import io.vertx.codegen.annotations.DataObject;
import io.vertx.core.json.JsonObject;
import java.util.ArrayList;
import java.util.List;
public class Path {
private boolean isOpen;
private List<Point> points;
public Path() {
this(false, new ArrayList<>());
}
public Path(boolean isOpen, List<Point> points) {
this.isOpen = isOpen;
this.points = points;
}
public boolean isOpen() {
return isOpen;
}
public void setOpen(boolean open) {
isOpen = open;
}
public List<Point> getPoints() {
return points;
}
public void setPoints(List<Point> points) {
this.points = points;
}
public Path addPoint(Point 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;
Path path = (Path) o;
if (isOpen != path.isOpen) return false;
return points.equals(path.points);
}
@Override
public int hashCode() {
int result = (isOpen ? 1 : 0);
result = 31 * result + points.hashCode();
return result;
}
@Override
public String toString() {
String left;
String right;
if (isOpen) {
left = "[";
right = "]";
} else {
left = "(";
right = ")";
}
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("Path");
stringBuilder.append(left);
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(right);
return stringBuilder.toString();
}
}