private boolean checkResponseItem(ResponseItem myItem, ResponseItem providerItem) {
    boolean match = true;
    if (!myItem.getDecision().equals(providerItem.getDecision())) {
      return false;
    }

    RequestItem myRequestItem = myItem.getRequestItem();
    RequestItem providerRequestItem = providerItem.getRequestItem();

    // check Actions

    List<Action> myActions = myRequestItem.getActions();
    List<Action> providerActions = providerRequestItem.getActions();

    for (Action providerAction : providerActions) {
      if ((!this.containsAction(providerAction, myActions))) {
        return false;
      }
    }

    // check Conditions

    List<Condition> myConditions = myRequestItem.getConditions();
    List<Condition> providerConditions = providerRequestItem.getConditions();

    for (Condition myCondition : myConditions) {
      if ((!this.containsCondition(myCondition, providerConditions))) {
        return false;
      }
    }

    return match;
  }
  private ResponseItem containsItem(ResponseItem item, List<ResponseItem> list) {
    for (ResponseItem r : list) {
      if (item.getRequestItem()
          .getResource()
          .getDataType()
          .equals(r.getRequestItem().getResource().getDataType())) {
        return r;
      }
    }

    return null;
  }
  public boolean checkResponse(ResponsePolicy myPolicy, ResponsePolicy providerPolicy) {

    for (ResponseItem providerItem : providerPolicy.getResponseItems()) {
      ResponseItem item = containsItem(providerItem, myPolicy.getResponseItems());
      if (item == null) {

        return false;
      } else {
        if (!checkResponseItem(item, providerItem)) {
          return false;
        } else {
          RequestItem requestItem = providerItem.getRequestItem();
          providerItem = new ResponseItem(requestItem, Decision.PERMIT);
        }
      }
    }

    return true;
  }