* @param updated updated RoleTO
* @param original original RoleTO
* @return RoleMod containing differences
*/
public static RoleMod diff(final RoleTO updated, final RoleTO original) {
RoleMod result = new RoleMod();
diff(updated, original, result, false);
// 1. inheritance
result.setInheritAccountPolicy(updated.isInheritAccountPolicy());
result.setInheritPasswordPolicy(updated.isInheritPasswordPolicy());
result.setInheritAttributes(updated.isInheritAttributes());
result.setInheritDerivedAttributes(updated.isInheritDerivedAttributes());
result.setInheritVirtualAttributes(updated.isInheritVirtualAttributes());
// 2. policies
ReferenceMod refAccountPolicy = new ReferenceMod();
refAccountPolicy.setId(updated.getAccountPolicy());
result.setAccountPolicy(refAccountPolicy);
ReferenceMod refPasswordPolicy = new ReferenceMod();
refPasswordPolicy.setId(updated.getPasswordPolicy());
result.setPasswordPolicy(refPasswordPolicy);
// 3. name
if (!original.getName().equals(updated.getName())) {
result.setName(updated.getName());
}
// 4. entitlements
Set<String> updatedEnts = new HashSet<String>(updated.getEntitlements());
Set<String> originalEnts = new HashSet<String>(original.getEntitlements());
if (!updatedEnts.equals(originalEnts)) {
result.setEntitlements(updated.getEntitlements());
}
return result;
}