コード例 #1
0
 /**
  * The descriptions of the policies.
  *
  * <p>Returns a reference to this object so that method calls can be chained together.
  *
  * @param policies The descriptions of the policies.
  * @return A reference to this updated object so that method calls can be chained together.
  */
 public ListPoliciesResult withPolicies(Policy... policies) {
   if (getPolicies() == null) setPolicies(new java.util.ArrayList<Policy>(policies.length));
   for (Policy value : policies) {
     getPolicies().add(value);
   }
   return this;
 }
  public ListPoliciesResult unmarshall(JsonUnmarshallerContext context) throws Exception {
    ListPoliciesResult listPoliciesResult = new ListPoliciesResult();

    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("policies", targetDepth)) {
          context.nextToken();
          listPoliciesResult.setPolicies(
              new ListUnmarshaller<Policy>(PolicyJsonUnmarshaller.getInstance())
                  .unmarshall(context));
        }
        if (context.testExpression("nextMarker", targetDepth)) {
          context.nextToken();
          listPoliciesResult.setNextMarker(
              context.getUnmarshaller(String.class).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 listPoliciesResult;
  }