I am bit confuse to use Strategy Pattern in my below case.
I have Contact class which is below.
public class Contact {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(columnDefinition = "INTEGER(11) UNSIGNED")
private long id;
@Column(columnDefinition = "INTEGER(11) UNSIGNED", nullable = false)
private long userId;
@Column(columnDefinition = "VARCHAR(255)")
String firstname;
@Column(columnDefinition = "VARCHAR(255)")
String lastname;
// other fields
I have below scenario that
- getContact(long user_id) which accepts user_id as parameter and return List which have same user_id from database.
- updateContact(Contact contact) which accepts Contact as parameter and update this contact in database.
- deleteContact(long contactID) which accepts ContactID as parameter and delete this contact in database.
-
addContact(Contact contact) which accepts Contact as parameter and add this contact in database.
Strategy Pattern with Java with above requirement. I can use Strategy Pattern in Java if method has similar input parameter and similar output parameter. But for my case I have different input parameter and different output parameter so I am confuse that how can I use Strategy Pattern. Please guide me on this case.
Aucun commentaire:
Enregistrer un commentaire