Skip to content

Commit

Permalink
use a shallow copy of the points in json wrapper, closes #42
Browse files Browse the repository at this point in the history
  • Loading branch information
granny committed May 13, 2024
1 parent ad5749f commit 36cfdf4
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,9 @@ public Polyline(@NotNull String key, @NotNull Collection<@NotNull Point> points)
* @return this line
*/
public @NotNull Polyline loop() {
Preconditions.checkState(this.points.size() > 0, "No points to loop back on");
Point first = this.points.get(0);
Point last = this.points.get(this.points.size() - 1);
Preconditions.checkState(!this.points.isEmpty(), "No points to loop back on");
Point first = this.points.getFirst();
Point last = this.points.getLast();
Preconditions.checkState(!first.equals(last), "First and last points are the same");
this.points.add(first);
return this;
Expand Down Expand Up @@ -269,7 +269,7 @@ public Polyline(@NotNull String key, @NotNull Collection<@NotNull Point> points)
public @NotNull JsonObject toJson() {
JsonObjectWrapper wrapper = new JsonObjectWrapper();
wrapper.addProperty("key", getKey());
wrapper.addProperty("points", getPoints());
wrapper.addProperty("points", new ArrayList<>(getPoints()));
wrapper.addProperty("pane", getPane());
return wrapper.getJsonObject();
}
Expand Down

0 comments on commit 36cfdf4

Please sign in to comment.