result.setInheritAttributes(updated.isInheritAttributes());
result.setInheritDerivedAttributes(updated.isInheritDerivedAttributes());
result.setInheritVirtualAttributes(updated.isInheritVirtualAttributes());
// 2. policies
result.setAccountPolicy(new ReferenceMod(updated.getAccountPolicy()));
result.setPasswordPolicy(new ReferenceMod(updated.getPasswordPolicy()));
// 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(null);
} else {
result.setEntitlements(updated.getEntitlements());
}
// 5. owner
result.setUserOwner(new ReferenceMod(updated.getUserOwner()));
result.setRoleOwner(new ReferenceMod(updated.getRoleOwner()));
return result;
}