There can be two types of groups- private and public. Each group can have members in it. I have three parameters id, includePrivate, includePublic to be passed into a method to return the groups as per the rules below. For eg.
public List<Group> getListofGroups(String id, Boolean isPrivate, Boolean isPublic){}
- All groups {}
- all private groups {"includePrivate": true}
- all public groups {"includePublic": true}
- all private groups with membership {"id":"id1", "includePrivate": true }
- all private groups with membership + all public groups {"id":"id1", "includePrivate": true, "includePublic": true }
What is the best way to implement this complex if/else logic? Is it a good option to create a rules engine just for this api?
For eg. if(isPrivate && isPublic && id=!null) {
return publicAndPrivateWIthMembership();
} else if(isPrivate && id=!null ) {
return privateGroupsWithMembership();
} else if((isPublic && !isPrivate) ||(isPublic && isPrivate == null) ) {
return allPublicGroups();
} else if((isPrivate && !isPublic) ||(isPrivate && isPublic == null) ) {
return allPrivateGroups();
}........