// check for "null" and "empty" policy: if such policy is found return "null" policy,
// or if all policies are "empty", return "empty" policy
boolean found = false;
boolean allPoliciesEmpty = true;
NamespaceVersion latestVersion = null;
for (Policy tested : policies) {
if (tested.isEmpty()) {
found = true;
} else {
if (tested.isNull()) {
found = true;
}
allPoliciesEmpty = false;
}
if (latestVersion == null) {
latestVersion = tested.getNamespaceVersion();
} else if (latestVersion.compareTo(tested.getNamespaceVersion()) < 0) {
latestVersion = tested.getNamespaceVersion();
}
if (found && !allPoliciesEmpty) {
return Policy.createNullPolicy(latestVersion, null, null);