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

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

    if (other.getName() == null ^ this.getName() == null) return false;
    if (other.getName() != null && other.getName().equals(this.getName()) == false) return false;
    if (other.getUniqueId() == null ^ this.getUniqueId() == null) return false;
    if (other.getUniqueId() != null && other.getUniqueId().equals(this.getUniqueId()) == false)
      return false;
    if (other.getDescription() == null ^ this.getDescription() == null) return false;
    if (other.getDescription() != null
        && other.getDescription().equals(this.getDescription()) == false) return false;
    return true;
  }
  public Request<CreatePipelineRequest> marshall(CreatePipelineRequest createPipelineRequest) {
    if (createPipelineRequest == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    Request<CreatePipelineRequest> request =
        new DefaultRequest<CreatePipelineRequest>(createPipelineRequest, "DataPipeline");
    String target = "DataPipeline.CreatePipeline";
    request.addHeader("X-Amz-Target", target);

    request.setHttpMethod(HttpMethodName.POST);
    request.setResourcePath("");

    try {
      StringWriter stringWriter = new StringWriter();
      JSONWriter jsonWriter = new JSONWriter(stringWriter);

      jsonWriter.object();

      if (createPipelineRequest.getName() != null) {
        jsonWriter.key("name").value(createPipelineRequest.getName());
      }
      if (createPipelineRequest.getUniqueId() != null) {
        jsonWriter.key("uniqueId").value(createPipelineRequest.getUniqueId());
      }
      if (createPipelineRequest.getDescription() != null) {
        jsonWriter.key("description").value(createPipelineRequest.getDescription());
      }

      jsonWriter.endObject();

      String snippet = stringWriter.toString();
      byte[] content = snippet.getBytes(UTF8);
      request.setContent(new StringInputStream(snippet));
      request.addHeader("Content-Length", Integer.toString(content.length));
      request.addHeader("Content-Type", "application/x-amz-json-1.1");
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }

    return request;
  }