import java.time.LocalDate; import java.util.ArrayList; import java.util.Collections; import java.util.List; import static java.util.Objects.requireNonNull; public final class Pet { private String id; private String name; private String owner; private String contactInformation; private String breed; private int age; private LocalDate registrationDate; private final List appointments = new ArrayList<>(); public Pet(String id, String name, String owner, String contactInformation, String breed, int age, LocalDate registrationDate) { if (age < 0) throw new IllegalArgumentException("Age must be over 0"); this.age = age; this.id = requireNonNull(id, "id must not be null"); this.name = requireNonNull(name, "Name must not be null"); this.owner = requireNonNull(owner, "Owner must not be null"); this.contactInformation = requireNonNull(contactInformation, "Contact information must not be null"); this.breed = requireNonNull(breed, "Breed must not be null"); this.registrationDate = requireNonNull(registrationDate, "Registration date must not be null"); } public void addAppointment(Appointment appointment) { this.appointments.add(requireNonNull(appointment, "Appointment must not be null")); } public String getId() { return id; } public String getName() { return name; } public String getOwner() { return owner; } public String getContactInformation() { return contactInformation; } public String getBreed() { return breed; } public int getAge() { return age; } public LocalDate getRegistrationDate() { return registrationDate; } public List getAppointments() { return Collections.unmodifiableList(appointments); } public void setId(String id) { this.id = requireNonNull(id, "id must not be null"); } public void setName(String name) { this.name = requireNonNull(name, "Name must not be null"); } public void setOwner(String owner) { this.owner = requireNonNull(owner, "Owner must not be null"); } public void setContactInformation(String contactInformation) { this.contactInformation =requireNonNull(contactInformation, "Contact information must not be null"); } public void setBreed(String breed) { this.breed = requireNonNull(breed, "Breed must not be null"); } public void setAge(int age) { if (age < 0) throw new IllegalArgumentException("Age must be over 0"); this.age = age; } public void setRegistrationDate(LocalDate registrationDate) { this.registrationDate = requireNonNull(registrationDate, "Registration date must not be null"); } @Override public String toString() { return "Pet{" + "id='" + id + '\'' + ", name='" + name + '\'' + ", owner='" + owner + '\'' + ", contactInformation='" + contactInformation + '\'' + ", breed='" + breed + '\'' + ", age=" + age + ", registrationDate=" + registrationDate + ", appointments=" + appointments + '}'; } }