Ejemplo n.º 1
0
 /**
  * A list of read-only fields that contain metadata about the pipeline:
  *
  * @userId, @accountId, and @pipelineState.
  *     <p>Returns a reference to this object so that method calls can be chained together.
  * @param fields A list of read-only fields that contain metadata about the pipeline:
  * @userId, @accountId, and @pipelineState.
  * @return A reference to this updated object so that method calls can be chained together.
  */
 public PipelineDescription withFields(Field... fields) {
   if (getFields() == null) setFields(new java.util.ArrayList<Field>(fields.length));
   for (Field value : fields) {
     getFields().add(value);
   }
   return this;
 }
  public PipelineDescription unmarshall(JsonUnmarshallerContext context) throws Exception {
    PipelineDescription pipelineDescription = new PipelineDescription();

    int originalDepth = context.getCurrentDepth();
    String currentParentElement = context.getCurrentParentElement();
    int targetDepth = originalDepth + 1;

    JsonToken token = context.getCurrentToken();
    if (token == null) token = context.nextToken();
    if (token == VALUE_NULL) return null;

    while (true) {
      if (token == null) break;

      if (token == FIELD_NAME || token == START_OBJECT) {
        if (context.testExpression("pipelineId", targetDepth)) {
          context.nextToken();
          pipelineDescription.setPipelineId(
              StringJsonUnmarshaller.getInstance().unmarshall(context));
        }
        if (context.testExpression("name", targetDepth)) {
          context.nextToken();
          pipelineDescription.setName(StringJsonUnmarshaller.getInstance().unmarshall(context));
        }
        if (context.testExpression("fields", targetDepth)) {
          context.nextToken();
          pipelineDescription.setFields(
              new ListUnmarshaller<Field>(FieldJsonUnmarshaller.getInstance()).unmarshall(context));
        }
        if (context.testExpression("description", targetDepth)) {
          context.nextToken();
          pipelineDescription.setDescription(
              StringJsonUnmarshaller.getInstance().unmarshall(context));
        }
        if (context.testExpression("tags", targetDepth)) {
          context.nextToken();
          pipelineDescription.setTags(
              new ListUnmarshaller<Tag>(TagJsonUnmarshaller.getInstance()).unmarshall(context));
        }
      } else if (token == END_ARRAY || token == END_OBJECT) {
        if (context.getLastParsedParentElement() == null
            || context.getLastParsedParentElement().equals(currentParentElement)) {
          if (context.getCurrentDepth() <= originalDepth) break;
        }
      }

      token = context.nextToken();
    }

    return pipelineDescription;
  }