I have a class:
@Getter
@Setter
public class Message {
private String sender;
private Set<String> receivers;
private String text;
}
The Message
class can be extended by EmailMessage
and SMSMessage
having their own additional fields.
There are 2 services - EmailService and SMSService. They both do the following operations:
- Take the message object which contains sender and receiver user ids.
- EmailService calls another service to transform the user ids to email ids. SMSService does the same to transform the user ids to phone numbers.
- The Message object should be transformed to EmailMessage and SMSMEssage in their respective services.
- Send the EmailMessage and SMSMessage.
Which design pattern will be best suitable for the above transformation? Or is there a better way to do this?
Aucun commentaire:
Enregistrer un commentaire