if (ROLE_TYPE.equalsIgnoreCase(type)) {
visibilityType = Visibility.Type.ROLE;
} else if (GROUP_TYPE.equalsIgnoreCase(type)) {
visibilityType = Visibility.Type.GROUP;
} else {
throw new JSONException("[" + type + "] does not represent a valid visibility type. Expected ["
+ ROLE_TYPE + "] or [" + GROUP_TYPE + "].");
}
final String value = json.getString("value");
return new Visibility(visibilityType, value);
}