@Override
public State get(Object key) {
if (key == null) {
return null;
}
final Permission permission;
if (key instanceof Permission) {
permission = (Permission) key;
} else {
permission = Permission.valueOf(String.valueOf(key));
}
State result = super.get(permission);
if (result == null) {
result = new State() {
@Override
public void setState(Boolean state) {
super.setState(state);
if (state != null) {
setDependentPermissions(state);
}
}
@Override
public void setDependent(boolean dependent) {
super.setDependent(dependent);
setDependentPermissions(dependent);
}
private void setDependentPermissions(boolean value) {
Collection<Permission> dependentPermissions = permission.getDependent();
for (Permission dependentPermission : dependentPermissions) {
get(dependentPermission).setDependent(value);
}
Collection<PermissionGroup> dependentPermissionGroups = permissionGroup.getDependent();
for (PermissionGroup dependentPermissionGroup : dependentPermissionGroups) {