Exemplo n.º 1
0
  public Job unmarshall(JsonUnmarshallerContext context) throws Exception {
    Job job = new Job();

    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("id", targetDepth)) {
          context.nextToken();
          job.setId(StringJsonUnmarshaller.getInstance().unmarshall(context));
        }
        if (context.testExpression("data", targetDepth)) {
          context.nextToken();
          job.setData(JobDataJsonUnmarshaller.getInstance().unmarshall(context));
        }
        if (context.testExpression("nonce", targetDepth)) {
          context.nextToken();
          job.setNonce(StringJsonUnmarshaller.getInstance().unmarshall(context));
        }
        if (context.testExpression("accountId", targetDepth)) {
          context.nextToken();
          job.setAccountId(StringJsonUnmarshaller.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 job;
  }
  public ListPipelinesResult unmarshall(JsonUnmarshallerContext context) throws Exception {
    ListPipelinesResult listPipelinesResult = new ListPipelinesResult();

    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("pipelines", targetDepth)) {
          context.nextToken();
          listPipelinesResult.setPipelines(
              new ListUnmarshaller<PipelineSummary>(PipelineSummaryJsonUnmarshaller.getInstance())
                  .unmarshall(context));
        }
        if (context.testExpression("nextToken", targetDepth)) {
          context.nextToken();
          listPipelinesResult.setNextToken(
              StringJsonUnmarshaller.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 listPipelinesResult;
  }