/** * Checks if a given policy contains no policy components * or if it has only empty ExactlyOne or All components * containing no assertions * * @param p the policy * @return true if the policy is empty */ public static boolean isEmptyPolicy(Policy p) { return isEmptyPolicyOperator(p); }
/** * Checks if a given policy contains no policy components * or if it has only empty ExactlyOne or All components * containing no assertions * * @param p the policy * @return true if the policy is empty */ public static boolean isEmptyPolicy(Policy p) { return isEmptyPolicyOperator(p); }
/** * Checks if a given policy operator has no policy components * or if it has only empty ExactlyOne or All components * containing no assertions * * @param p the policy operator * @return true if this policy operator is empty */ public static boolean isEmptyPolicyOperator(PolicyOperator p) { if (p.isEmpty()) { return true; } for (PolicyComponent component : p.getPolicyComponents()) { if (!(component instanceof PolicyOperator) || !isEmptyPolicyOperator((PolicyOperator)component)) { return false; } } return true; }
/** * Checks if a given policy operator has no policy components * or if it has only empty ExactlyOne or All components * containing no assertions * * @param p the policy operator * @return true if this policy operator is empty */ public static boolean isEmptyPolicyOperator(PolicyOperator p) { if (p.isEmpty()) { return true; } for (PolicyComponent component : p.getPolicyComponents()) { if (!(component instanceof PolicyOperator) || !isEmptyPolicyOperator((PolicyOperator)component)) { return false; } } return true; }