xyz.jpenilla.squaremap.api.marker.Polygon Maven / Gradle / Ivy
package xyz.jpenilla.squaremap.api.marker;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import xyz.jpenilla.squaremap.api.Point;
/**
* Polygon marker
*/
public final class Polygon extends Marker implements IPolygon {
private final List mainPolygon;
private final List> negativeSpace;
Polygon(final @NonNull List points, final @NonNull List> negativeSpace) {
this.mainPolygon = new ArrayList<>(points);
this.negativeSpace = new ArrayList<>(negativeSpace);
}
@Override
public @NonNull List> negativeSpace() {
return this.negativeSpace;
}
@Override
public @NonNull List mainPolygon() {
return this.mainPolygon;
}
@Override
public boolean equals(final @Nullable Object o) {
if (this == o) {
return true;
}
if (o == null || this.getClass() != o.getClass()) {
return false;
}
final @Nullable Polygon polygon = (Polygon) o;
return this.markerOptionsMatch(polygon)
&& this.mainPolygon.equals(polygon.mainPolygon)
&& this.negativeSpace.equals(polygon.negativeSpace);
}
@Override
public int hashCode() {
return Objects.hash(this.markerOptions(), this.mainPolygon, this.negativeSpace);
}
}