コード例 #1
0
  @Override
  public boolean equals(Object obj) {
    if (this == obj) return true;
    if (obj == null) return false;

    if (obj instanceof AuthorizeSecurityGroupEgressRequest == false) return false;
    AuthorizeSecurityGroupEgressRequest other = (AuthorizeSecurityGroupEgressRequest) obj;

    if (other.getGroupId() == null ^ this.getGroupId() == null) return false;
    if (other.getGroupId() != null && other.getGroupId().equals(this.getGroupId()) == false)
      return false;
    if (other.getSourceSecurityGroupName() == null ^ this.getSourceSecurityGroupName() == null)
      return false;
    if (other.getSourceSecurityGroupName() != null
        && other.getSourceSecurityGroupName().equals(this.getSourceSecurityGroupName()) == false)
      return false;
    if (other.getSourceSecurityGroupOwnerId() == null
        ^ this.getSourceSecurityGroupOwnerId() == null) return false;
    if (other.getSourceSecurityGroupOwnerId() != null
        && other.getSourceSecurityGroupOwnerId().equals(this.getSourceSecurityGroupOwnerId())
            == false) return false;
    if (other.getIpProtocol() == null ^ this.getIpProtocol() == null) return false;
    if (other.getIpProtocol() != null
        && other.getIpProtocol().equals(this.getIpProtocol()) == false) return false;
    if (other.getFromPort() == null ^ this.getFromPort() == null) return false;
    if (other.getFromPort() != null && other.getFromPort().equals(this.getFromPort()) == false)
      return false;
    if (other.getToPort() == null ^ this.getToPort() == null) return false;
    if (other.getToPort() != null && other.getToPort().equals(this.getToPort()) == false)
      return false;
    if (other.getCidrIp() == null ^ this.getCidrIp() == null) return false;
    if (other.getCidrIp() != null && other.getCidrIp().equals(this.getCidrIp()) == false)
      return false;
    if (other.getIpPermissions() == null ^ this.getIpPermissions() == null) return false;
    if (other.getIpPermissions() != null
        && other.getIpPermissions().equals(this.getIpPermissions()) == false) return false;
    return true;
  }
  public Request<AuthorizeSecurityGroupEgressRequest> marshall(
      AuthorizeSecurityGroupEgressRequest authorizeSecurityGroupEgressRequest) {

    if (authorizeSecurityGroupEgressRequest == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    Request<AuthorizeSecurityGroupEgressRequest> request =
        new DefaultRequest<AuthorizeSecurityGroupEgressRequest>(
            authorizeSecurityGroupEgressRequest, "AmazonEC2");
    request.addParameter("Action", "AuthorizeSecurityGroupEgress");
    request.addParameter("Version", "2014-06-15");

    if (authorizeSecurityGroupEgressRequest.getGroupId() != null) {
      request.addParameter(
          "GroupId", StringUtils.fromString(authorizeSecurityGroupEgressRequest.getGroupId()));
    }
    if (authorizeSecurityGroupEgressRequest.getSourceSecurityGroupName() != null) {
      request.addParameter(
          "SourceSecurityGroupName",
          StringUtils.fromString(authorizeSecurityGroupEgressRequest.getSourceSecurityGroupName()));
    }
    if (authorizeSecurityGroupEgressRequest.getSourceSecurityGroupOwnerId() != null) {
      request.addParameter(
          "SourceSecurityGroupOwnerId",
          StringUtils.fromString(
              authorizeSecurityGroupEgressRequest.getSourceSecurityGroupOwnerId()));
    }
    if (authorizeSecurityGroupEgressRequest.getIpProtocol() != null) {
      request.addParameter(
          "IpProtocol",
          StringUtils.fromString(authorizeSecurityGroupEgressRequest.getIpProtocol()));
    }
    if (authorizeSecurityGroupEgressRequest.getFromPort() != null) {
      request.addParameter(
          "FromPort", StringUtils.fromInteger(authorizeSecurityGroupEgressRequest.getFromPort()));
    }
    if (authorizeSecurityGroupEgressRequest.getToPort() != null) {
      request.addParameter(
          "ToPort", StringUtils.fromInteger(authorizeSecurityGroupEgressRequest.getToPort()));
    }
    if (authorizeSecurityGroupEgressRequest.getCidrIp() != null) {
      request.addParameter(
          "CidrIp", StringUtils.fromString(authorizeSecurityGroupEgressRequest.getCidrIp()));
    }

    java.util.List<IpPermission> ipPermissionsList =
        authorizeSecurityGroupEgressRequest.getIpPermissions();
    int ipPermissionsListIndex = 1;

    for (IpPermission ipPermissionsListValue : ipPermissionsList) {
      IpPermission ipPermissionMember = ipPermissionsListValue;
      if (ipPermissionMember != null) {
        if (ipPermissionMember.getIpProtocol() != null) {
          request.addParameter(
              "IpPermissions." + ipPermissionsListIndex + ".IpProtocol",
              StringUtils.fromString(ipPermissionMember.getIpProtocol()));
        }
        if (ipPermissionMember.getFromPort() != null) {
          request.addParameter(
              "IpPermissions." + ipPermissionsListIndex + ".FromPort",
              StringUtils.fromInteger(ipPermissionMember.getFromPort()));
        }
        if (ipPermissionMember.getToPort() != null) {
          request.addParameter(
              "IpPermissions." + ipPermissionsListIndex + ".ToPort",
              StringUtils.fromInteger(ipPermissionMember.getToPort()));
        }

        java.util.List<UserIdGroupPair> userIdGroupPairsList =
            ipPermissionMember.getUserIdGroupPairs();
        int userIdGroupPairsListIndex = 1;

        for (UserIdGroupPair userIdGroupPairsListValue : userIdGroupPairsList) {
          UserIdGroupPair userIdGroupPairMember = userIdGroupPairsListValue;
          if (userIdGroupPairMember != null) {
            if (userIdGroupPairMember.getUserId() != null) {
              request.addParameter(
                  "IpPermissions."
                      + ipPermissionsListIndex
                      + ".Groups."
                      + userIdGroupPairsListIndex
                      + ".UserId",
                  StringUtils.fromString(userIdGroupPairMember.getUserId()));
            }
            if (userIdGroupPairMember.getGroupName() != null) {
              request.addParameter(
                  "IpPermissions."
                      + ipPermissionsListIndex
                      + ".Groups."
                      + userIdGroupPairsListIndex
                      + ".GroupName",
                  StringUtils.fromString(userIdGroupPairMember.getGroupName()));
            }
            if (userIdGroupPairMember.getGroupId() != null) {
              request.addParameter(
                  "IpPermissions."
                      + ipPermissionsListIndex
                      + ".Groups."
                      + userIdGroupPairsListIndex
                      + ".GroupId",
                  StringUtils.fromString(userIdGroupPairMember.getGroupId()));
            }
          }

          userIdGroupPairsListIndex++;
        }

        java.util.List<String> ipRangesList = ipPermissionMember.getIpRanges();
        int ipRangesListIndex = 1;

        for (String ipRangesListValue : ipRangesList) {
          if (ipRangesListValue != null) {
            request.addParameter(
                "IpPermissions."
                    + ipPermissionsListIndex
                    + ".IpRanges."
                    + ipRangesListIndex
                    + ".CidrIp",
                StringUtils.fromString(ipRangesListValue));
          }

          ipRangesListIndex++;
        }
      }

      ipPermissionsListIndex++;
    }

    return request;
  }