public Request<SetLoadBasedAutoScalingRequest> marshall(
      SetLoadBasedAutoScalingRequest setLoadBasedAutoScalingRequest) {

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

    Request<SetLoadBasedAutoScalingRequest> request =
        new DefaultRequest<SetLoadBasedAutoScalingRequest>(
            setLoadBasedAutoScalingRequest, "AWSOpsWorks");
    request.addHeader("X-Amz-Target", "OpsWorks_20130218.SetLoadBasedAutoScaling");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

    try {
      final StructuredJsonGenerator jsonGenerator = protocolFactory.createGenerator();

      jsonGenerator.writeStartObject();

      if (setLoadBasedAutoScalingRequest.getLayerId() != null) {
        jsonGenerator
            .writeFieldName("LayerId")
            .writeValue(setLoadBasedAutoScalingRequest.getLayerId());
      }
      if (setLoadBasedAutoScalingRequest.getEnable() != null) {
        jsonGenerator
            .writeFieldName("Enable")
            .writeValue(setLoadBasedAutoScalingRequest.getEnable());
      }
      if (setLoadBasedAutoScalingRequest.getUpScaling() != null) {
        jsonGenerator.writeFieldName("UpScaling");
        AutoScalingThresholdsJsonMarshaller.getInstance()
            .marshall(setLoadBasedAutoScalingRequest.getUpScaling(), jsonGenerator);
      }
      if (setLoadBasedAutoScalingRequest.getDownScaling() != null) {
        jsonGenerator.writeFieldName("DownScaling");
        AutoScalingThresholdsJsonMarshaller.getInstance()
            .marshall(setLoadBasedAutoScalingRequest.getDownScaling(), jsonGenerator);
      }

      jsonGenerator.writeEndObject();

      byte[] content = jsonGenerator.getBytes();
      request.setContent(new ByteArrayInputStream(content));
      request.addHeader("Content-Length", Integer.toString(content.length));
      request.addHeader("Content-Type", protocolFactory.getContentType());
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }

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

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

    if (other.getLayerId() == null ^ this.getLayerId() == null) return false;
    if (other.getLayerId() != null && other.getLayerId().equals(this.getLayerId()) == false)
      return false;
    if (other.isEnable() == null ^ this.isEnable() == null) return false;
    if (other.isEnable() != null && other.isEnable().equals(this.isEnable()) == false) return false;
    if (other.getUpScaling() == null ^ this.getUpScaling() == null) return false;
    if (other.getUpScaling() != null && other.getUpScaling().equals(this.getUpScaling()) == false)
      return false;
    if (other.getDownScaling() == null ^ this.getDownScaling() == null) return false;
    if (other.getDownScaling() != null
        && other.getDownScaling().equals(this.getDownScaling()) == false) return false;
    return true;
  }