コード例 #1
0
  public MethodSetting unmarshall(JsonUnmarshallerContext context) throws Exception {
    MethodSetting methodSetting = new MethodSetting();

    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("metricsEnabled", targetDepth)) {
          context.nextToken();
          methodSetting.setMetricsEnabled(
              BooleanJsonUnmarshaller.getInstance().unmarshall(context));
        }
        if (context.testExpression("loggingLevel", targetDepth)) {
          context.nextToken();
          methodSetting.setLoggingLevel(StringJsonUnmarshaller.getInstance().unmarshall(context));
        }
        if (context.testExpression("dataTraceEnabled", targetDepth)) {
          context.nextToken();
          methodSetting.setDataTraceEnabled(
              BooleanJsonUnmarshaller.getInstance().unmarshall(context));
        }
        if (context.testExpression("throttlingBurstLimit", targetDepth)) {
          context.nextToken();
          methodSetting.setThrottlingBurstLimit(
              IntegerJsonUnmarshaller.getInstance().unmarshall(context));
        }
        if (context.testExpression("throttlingRateLimit", targetDepth)) {
          context.nextToken();
          methodSetting.setThrottlingRateLimit(
              DoubleJsonUnmarshaller.getInstance().unmarshall(context));
        }
        if (context.testExpression("cachingEnabled", targetDepth)) {
          context.nextToken();
          methodSetting.setCachingEnabled(
              BooleanJsonUnmarshaller.getInstance().unmarshall(context));
        }
        if (context.testExpression("cacheTtlInSeconds", targetDepth)) {
          context.nextToken();
          methodSetting.setCacheTtlInSeconds(
              IntegerJsonUnmarshaller.getInstance().unmarshall(context));
        }
        if (context.testExpression("cacheDataEncrypted", targetDepth)) {
          context.nextToken();
          methodSetting.setCacheDataEncrypted(
              BooleanJsonUnmarshaller.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 methodSetting;
  }
コード例 #2
0
  public Method unmarshall(JsonUnmarshallerContext context) throws Exception {
    Method method = new Method();

    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("httpMethod", targetDepth)) {
          context.nextToken();
          method.setHttpMethod(StringJsonUnmarshaller.getInstance().unmarshall(context));
        }
        if (context.testExpression("authorizationType", targetDepth)) {
          context.nextToken();
          method.setAuthorizationType(StringJsonUnmarshaller.getInstance().unmarshall(context));
        }
        if (context.testExpression("apiKeyRequired", targetDepth)) {
          context.nextToken();
          method.setApiKeyRequired(BooleanJsonUnmarshaller.getInstance().unmarshall(context));
        }
        if (context.testExpression("requestParameters", targetDepth)) {
          context.nextToken();
          method.setRequestParameters(
              new MapUnmarshaller<String, Boolean>(
                      StringJsonUnmarshaller.getInstance(), BooleanJsonUnmarshaller.getInstance())
                  .unmarshall(context));
        }
        if (context.testExpression("requestModels", targetDepth)) {
          context.nextToken();
          method.setRequestModels(
              new MapUnmarshaller<String, String>(
                      StringJsonUnmarshaller.getInstance(), StringJsonUnmarshaller.getInstance())
                  .unmarshall(context));
        }
        if (context.testExpression("methodResponses", targetDepth)) {
          context.nextToken();
          method.setMethodResponses(
              new MapUnmarshaller<String, MethodResponse>(
                      StringJsonUnmarshaller.getInstance(),
                      MethodResponseJsonUnmarshaller.getInstance())
                  .unmarshall(context));
        }
        if (context.testExpression("methodIntegration", targetDepth)) {
          context.nextToken();
          method.setMethodIntegration(
              IntegrationJsonUnmarshaller.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 method;
  }