I have two ArrayList userActions and actionsToCheck of type enum Action.
I want to check if all the elements in actionsToCheck is present in userActions.
Is the following good enough or is there a better way?
private boolean actionsAllowed(ArrayList<Action> userActions, ArrayList<Action> actionsToCheck){
return actionsToCheck.stream().allMatch(action-> actionAllowed(userActions,action));
}
private boolean actionAllowed(ArrayList<Actions> userActions, Action action){
return userActions.stream().anyMatch(userAction -> userAction == action);
}
ArrayList<Actions> userAction=new ArrayList<>();
userAction.add(ADD_USER);
userAction.add(DELETE_USER);
userAction.add(MODIFY_USER);
ArrayList<Actions> actionsToCheck=new ArrayList<>();
actionsToCheck.add(ADD_USER);
actionsToCheck.add(DELETE_USER);
actionsAllowed(userAction,actionsToCheck) //should return true