class OzoneAclUtil {

  public static boolean removeAcl(List<OzoneAcl> existingAcls, OzoneAcl acl) {
    if (existingAcls == null || existingAcls.isEmpty() || acl == null) {
      return false;
    }

    for (OzoneAcl a: existingAcls) {
      if (a.getName().equals(acl.getName()) &&
          a.getType().equals(acl.getType()) &&
          a.getAclScope().equals(acl.getAclScope())) {
        BitSet current = a.getAclBitSet();
        BitSet original = (BitSet) current.clone();
        current.andNot(acl.getAclBitSet());

        if (current.equals(original)) {
          return false;
        }

        if (current.isEmpty()) {
          existingAcls.remove(a);
        }
        return true;
      }
    }
    return false;
  }

  private  OzoneAclUtil();

}