/** Marshall the given parameter object, and output to a SdkJsonGenerator */ public void marshall(MethodSetting methodSetting, StructuredJsonGenerator jsonGenerator) { if (methodSetting == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } try { jsonGenerator.writeStartObject(); if (methodSetting.getMetricsEnabled() != null) { jsonGenerator .writeFieldName("metricsEnabled") .writeValue(methodSetting.getMetricsEnabled()); } if (methodSetting.getLoggingLevel() != null) { jsonGenerator.writeFieldName("loggingLevel").writeValue(methodSetting.getLoggingLevel()); } if (methodSetting.getDataTraceEnabled() != null) { jsonGenerator .writeFieldName("dataTraceEnabled") .writeValue(methodSetting.getDataTraceEnabled()); } if (methodSetting.getThrottlingBurstLimit() != null) { jsonGenerator .writeFieldName("throttlingBurstLimit") .writeValue(methodSetting.getThrottlingBurstLimit()); } if (methodSetting.getThrottlingRateLimit() != null) { jsonGenerator .writeFieldName("throttlingRateLimit") .writeValue(methodSetting.getThrottlingRateLimit()); } if (methodSetting.getCachingEnabled() != null) { jsonGenerator .writeFieldName("cachingEnabled") .writeValue(methodSetting.getCachingEnabled()); } if (methodSetting.getCacheTtlInSeconds() != null) { jsonGenerator .writeFieldName("cacheTtlInSeconds") .writeValue(methodSetting.getCacheTtlInSeconds()); } if (methodSetting.getCacheDataEncrypted() != null) { jsonGenerator .writeFieldName("cacheDataEncrypted") .writeValue(methodSetting.getCacheDataEncrypted()); } if (methodSetting.getRequireAuthorizationForCacheControl() != null) { jsonGenerator .writeFieldName("requireAuthorizationForCacheControl") .writeValue(methodSetting.getRequireAuthorizationForCacheControl()); } if (methodSetting.getUnauthorizedCacheControlHeaderStrategy() != null) { jsonGenerator .writeFieldName("unauthorizedCacheControlHeaderStrategy") .writeValue(methodSetting.getUnauthorizedCacheControlHeaderStrategy()); } jsonGenerator.writeEndObject(); } catch (Throwable t) { throw new SdkClientException("Unable to marshall request to JSON: " + t.getMessage(), t); } }
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; }