PageRenderTime 27ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/aws-java-sdk-lightsail/src/main/java/com/amazonaws/services/lightsail/model/transform/PortInfoJsonUnmarshaller.java

https://github.com/aws/aws-sdk-java
Java | 100 lines | 69 code | 16 blank | 15 comment | 28 complexity | ace53a2a3136cff583406fe49e3fd636 MD5 | raw file
  1. /*
  2. * Copyright 2016-2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
  5. * the License. A copy of the License is located at
  6. *
  7. * http://aws.amazon.com/apache2.0
  8. *
  9. * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
  10. * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
  11. * and limitations under the License.
  12. */
  13. package com.amazonaws.services.lightsail.model.transform;
  14. import java.math.*;
  15. import javax.annotation.Generated;
  16. import com.amazonaws.services.lightsail.model.*;
  17. import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*;
  18. import com.amazonaws.transform.*;
  19. import com.fasterxml.jackson.core.JsonToken;
  20. import static com.fasterxml.jackson.core.JsonToken.*;
  21. /**
  22. * PortInfo JSON Unmarshaller
  23. */
  24. @Generated("com.amazonaws:aws-java-sdk-code-generator")
  25. public class PortInfoJsonUnmarshaller implements Unmarshaller<PortInfo, JsonUnmarshallerContext> {
  26. public PortInfo unmarshall(JsonUnmarshallerContext context) throws Exception {
  27. PortInfo portInfo = new PortInfo();
  28. int originalDepth = context.getCurrentDepth();
  29. String currentParentElement = context.getCurrentParentElement();
  30. int targetDepth = originalDepth + 1;
  31. JsonToken token = context.getCurrentToken();
  32. if (token == null)
  33. token = context.nextToken();
  34. if (token == VALUE_NULL) {
  35. return null;
  36. }
  37. while (true) {
  38. if (token == null)
  39. break;
  40. if (token == FIELD_NAME || token == START_OBJECT) {
  41. if (context.testExpression("fromPort", targetDepth)) {
  42. context.nextToken();
  43. portInfo.setFromPort(context.getUnmarshaller(Integer.class).unmarshall(context));
  44. }
  45. if (context.testExpression("toPort", targetDepth)) {
  46. context.nextToken();
  47. portInfo.setToPort(context.getUnmarshaller(Integer.class).unmarshall(context));
  48. }
  49. if (context.testExpression("protocol", targetDepth)) {
  50. context.nextToken();
  51. portInfo.setProtocol(context.getUnmarshaller(String.class).unmarshall(context));
  52. }
  53. if (context.testExpression("cidrs", targetDepth)) {
  54. context.nextToken();
  55. portInfo.setCidrs(new ListUnmarshaller<String>(context.getUnmarshaller(String.class))
  56. .unmarshall(context));
  57. }
  58. if (context.testExpression("ipv6Cidrs", targetDepth)) {
  59. context.nextToken();
  60. portInfo.setIpv6Cidrs(new ListUnmarshaller<String>(context.getUnmarshaller(String.class))
  61. .unmarshall(context));
  62. }
  63. if (context.testExpression("cidrListAliases", targetDepth)) {
  64. context.nextToken();
  65. portInfo.setCidrListAliases(new ListUnmarshaller<String>(context.getUnmarshaller(String.class))
  66. .unmarshall(context));
  67. }
  68. } else if (token == END_ARRAY || token == END_OBJECT) {
  69. if (context.getLastParsedParentElement() == null || context.getLastParsedParentElement().equals(currentParentElement)) {
  70. if (context.getCurrentDepth() <= originalDepth)
  71. break;
  72. }
  73. }
  74. token = context.nextToken();
  75. }
  76. return portInfo;
  77. }
  78. private static PortInfoJsonUnmarshaller instance;
  79. public static PortInfoJsonUnmarshaller getInstance() {
  80. if (instance == null)
  81. instance = new PortInfoJsonUnmarshaller();
  82. return instance;
  83. }
  84. }