I am using a generic type parameter T for fields like replyTo, cc, and bcc. SmsId class and EmailID class are the generic class that I am using in the NotificationTemplateRepoDto<?> class.
While retrieving from the db, the replyTo/cc/bcc field is deserialized into a LinkedList of LinkedHashMap, not a List<EmailId > or List<SmsId>.
Is there any efficient solution for this to convert the object to the specific generics.
@Document(collection = "NotificationTemplate")
@Data
public class NotificationTemplateRepoDto<T> implements Serializable {
private String id;
private String name;
private String category;
private String lob;
private Type type;
private boolean active;
private LocalDateTime created;
private LocalDateTime updated;
private String owner;
private String body;
private List<Container> attachments;
private List<T> bcc;
private List<T> cc;
private T replyTo;
private String mediaType;
}
public class SmsId implements Serializable {
private int countryCode;
private long mobileNo;
}
@NoArgsConstructor
public class EmailId implements Serializable {
private String name;
private String id;
}
public interface NotificationTemplateRepository<T>
extends ReactiveMongoRepository<NotificationTemplateRepoDto<T>, String> {
}