Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import com.fasterxml.jackson.databind.ObjectMapper;
- import java.io.IOException;
- public class Notification {
- private String patientId;
- private String message;
- private Doctor assignedDoctor;
- private String nextAppointmentDate;
- public Notification() {
- }
- public Notification(String patientId, String message) {
- this.patientId = patientId;
- this.message = message;
- }
- public String getPatientId() {
- return patientId;
- }
- public void setPatientId(String patientId) {
- this.patientId = patientId;
- }
- public String getMessage() {
- return message;
- }
- public void setMessage(String message) {
- this.message = message;
- }
- public Doctor getAssignedDoctor() {
- return assignedDoctor;
- }
- public void setAssignedDoctor(Doctor assignedDoctor) {
- this.assignedDoctor = assignedDoctor;
- }
- public String getNextAppointmentDate() {
- return nextAppointmentDate;
- }
- public void setNextAppointmentDate(String nextAppointmentDate) {
- this.nextAppointmentDate = nextAppointmentDate;
- }
- // Методы для сериализации и десериализации JSON
- private static final ObjectMapper objectMapper = new ObjectMapper();
- public static Notification fromJson(String json) {
- try {
- return objectMapper.readValue(json, Notification.class);
- } catch (IOException e) {
- e.printStackTrace();
- return null;
- }
- }
- public String toJson() {
- try {
- return objectMapper.writeValueAsString(this);
- } catch (IOException e) {
- e.printStackTrace();
- return null;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment