From 7a87c716e85a12c72c24173b88b2e07729d85241 Mon Sep 17 00:00:00 2001 From: sowgro Date: Sun, 9 Nov 2025 01:01:03 -0500 Subject: complete serialization --- src/main/java/design/model/League.java | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'src/main/java/design/model/League.java') diff --git a/src/main/java/design/model/League.java b/src/main/java/design/model/League.java index 98c9bdd..eb9eef5 100644 --- a/src/main/java/design/model/League.java +++ b/src/main/java/design/model/League.java @@ -1,16 +1,19 @@ package design.model; +import com.fasterxml.jackson.annotation.JsonCreator; + import java.util.Date; public abstract class League { - private final int id; + private int id; private final String name; private final Date registrationDate; private final Date startDate; private final Date endDate; private final Golfer owner; - public League(int id, String name, Date registrationDate, Date startDate, Date endDate, Golfer owner) { + @JsonCreator + private League(int id, String name, Date registrationDate, Date startDate, Date endDate, Golfer owner) { this.id = id; this.name = name; this.registrationDate = registrationDate; @@ -19,6 +22,15 @@ public abstract class League { this.owner = owner; } + public League(String name, Date registrationDate, Date startDate, Date endDate, Golfer owner) { + this.id = -1; + this.name = name; + this.registrationDate = registrationDate; + this.startDate = startDate; + this.endDate = endDate; + this.owner = owner; + } + public int getId() { return id; } @@ -42,4 +54,9 @@ public abstract class League { public Golfer getOwner() { return owner; } + + public void setId(int id) { + assert this.id == -1; + this.id = id; + } } -- cgit v1.2.3