I am trying to implement the repository pattern to query users and the corresponding settings associated to each user. I am having a repository interface which has the crud operations to be implemented by each and every repository.
import java.util.List;
public interface Repository<T> {
void add(T item);
void add(Iterable<T> items);
void update(T item);
void remove(T item);
void remove(Specification specification);
List<T> query(Specification specification);
}
I am reading about the specification pattern but i do not understand how to apply the concept to my usecase.
I have two repositories which implements the Repository interface. My classes will be having the below operations which translate into the crud operations as mentioned in the interface
GetSettingsForUserIDMatchingSettingName(string userid, string settingname);
CreateSettingForProfile(string userid, Setting setting);
Create(string userid, Setting setting);
Update(string userid, Setting setting);
GetAllProfiles();
GetProfilesMatchingUserID(string userid);
GetSettingsForUserID(string userid);
GetProfilesForUserIDWithSettingName(string userid, string settingname);
How to create my specification class or interface so that my specification caters to all the use cases.
I am referring to the below github link to implement but i am lost.
Kindly, help.