1 /*
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License").
5  * You may not use this file except in compliance with the License.
6  * A copy of the License is located at
7  *
8  *  http://aws.amazon.com/apache2.0
9  *
10  * or in the "license" file accompanying this file. This file is distributed
11  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12  * express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */
15 
16 package software.amazon.awssdk.codegen.model.intermediate;
17 
18 import static software.amazon.awssdk.codegen.internal.Constant.LF;
19 import static software.amazon.awssdk.codegen.internal.DocumentationUtils.defaultExistenceCheck;
20 import static software.amazon.awssdk.codegen.internal.DocumentationUtils.defaultFluentReturn;
21 import static software.amazon.awssdk.codegen.internal.DocumentationUtils.defaultGetter;
22 import static software.amazon.awssdk.codegen.internal.DocumentationUtils.defaultGetterParam;
23 import static software.amazon.awssdk.codegen.internal.DocumentationUtils.defaultSetter;
24 import static software.amazon.awssdk.codegen.internal.DocumentationUtils.defaultSetterParam;
25 import static software.amazon.awssdk.codegen.internal.DocumentationUtils.stripHtmlTags;
26 
27 import com.fasterxml.jackson.annotation.JsonIgnore;
28 import com.squareup.javapoet.ClassName;
29 import java.util.List;
30 import java.util.Map;
31 import java.util.Optional;
32 import software.amazon.awssdk.codegen.internal.TypeUtils;
33 import software.amazon.awssdk.codegen.model.service.ContextParam;
34 import software.amazon.awssdk.core.SdkBytes;
35 import software.amazon.awssdk.core.SdkField;
36 import software.amazon.awssdk.core.protocol.MarshallingType;
37 import software.amazon.awssdk.core.util.SdkAutoConstructList;
38 import software.amazon.awssdk.core.util.SdkAutoConstructMap;
39 import software.amazon.awssdk.protocols.core.PathMarshaller;
40 import software.amazon.awssdk.utils.StringUtils;
41 
42 public class MemberModel extends DocumentationModel {
43 
44     private String name;
45 
46     private String c2jName;
47 
48     private String c2jShape;
49 
50     private VariableModel variable;
51 
52     private VariableModel setterModel;
53 
54     private ReturnTypeModel getterModel;
55 
56     private ParameterHttpMapping http;
57 
58     private boolean deprecated;
59 
60     private String deprecatedMessage;
61 
62     private boolean required;
63 
64     private boolean synthetic;
65 
66     private ListModel listModel;
67 
68     private MapModel mapModel;
69 
70     private String enumType;
71 
72     private String xmlNameSpaceUri;
73 
74     private boolean idempotencyToken;
75 
76     private ShapeModel shape;
77 
78     private String fluentGetterMethodName;
79 
80     private String fluentEnumGetterMethodName;
81 
82     private String fluentSetterMethodName;
83 
84     private String fluentEnumSetterMethodName;
85 
86     private String existenceCheckMethodName;
87 
88     private String beanStyleGetterName;
89 
90     private String beanStyleSetterName;
91 
92     private String unionEnumTypeName;
93 
94     private boolean isJsonValue;
95 
96     private String timestampFormat;
97 
98     private boolean eventPayload;
99 
100     private boolean eventHeader;
101 
102     private boolean endpointDiscoveryId;
103 
104     private boolean sensitive;
105 
106     private boolean xmlAttribute;
107 
108     private String deprecatedName;
109 
110     private String fluentDeprecatedGetterMethodName;
111 
112     private String fluentDeprecatedSetterMethodName;
113 
114     private String deprecatedBeanStyleSetterMethodName;
115 
116     private ContextParam contextParam;
117 
getName()118     public String getName() {
119         return name;
120     }
121 
setName(String name)122     public void setName(String name) {
123         this.name = name;
124     }
125 
withName(String name)126     public MemberModel withName(String name) {
127         setName(name);
128         return this;
129     }
130 
isSynthetic()131     public boolean isSynthetic() {
132         return synthetic;
133     }
134 
setSynthetic(boolean synthetic)135     public void setSynthetic(boolean synthetic) {
136         this.synthetic = synthetic;
137     }
138 
getC2jName()139     public String getC2jName() {
140         return c2jName;
141     }
142 
setC2jName(String c2jName)143     public void setC2jName(String c2jName) {
144         this.c2jName = c2jName;
145     }
146 
withC2jName(String c2jName)147     public MemberModel withC2jName(String c2jName) {
148         setC2jName(c2jName);
149         return this;
150     }
151 
getC2jShape()152     public String getC2jShape() {
153         return c2jShape;
154     }
155 
setC2jShape(String c2jShape)156     public void setC2jShape(String c2jShape) {
157         this.c2jShape = c2jShape;
158     }
159 
withC2jShape(String c2jShape)160     public MemberModel withC2jShape(String c2jShape) {
161         setC2jShape(c2jShape);
162         return this;
163     }
164 
getVariable()165     public VariableModel getVariable() {
166         return variable;
167     }
168 
setVariable(VariableModel variable)169     public void setVariable(VariableModel variable) {
170         this.variable = variable;
171     }
172 
withVariable(VariableModel variable)173     public MemberModel withVariable(VariableModel variable) {
174         setVariable(variable);
175         return this;
176     }
177 
getSetterModel()178     public VariableModel getSetterModel() {
179         return setterModel;
180     }
181 
setSetterModel(VariableModel setterModel)182     public void setSetterModel(VariableModel setterModel) {
183         this.setterModel = setterModel;
184     }
185 
withSetterModel(VariableModel setterModel)186     public MemberModel withSetterModel(VariableModel setterModel) {
187         setSetterModel(setterModel);
188         return this;
189     }
190 
getFluentGetterMethodName()191     public String getFluentGetterMethodName() {
192         return fluentGetterMethodName;
193     }
194 
setFluentGetterMethodName(String fluentGetterMethodName)195     public void setFluentGetterMethodName(String fluentGetterMethodName) {
196         this.fluentGetterMethodName = fluentGetterMethodName;
197     }
198 
withFluentGetterMethodName(String getterMethodName)199     public MemberModel withFluentGetterMethodName(String getterMethodName) {
200         setFluentGetterMethodName(getterMethodName);
201         return this;
202     }
203 
getFluentEnumGetterMethodName()204     public String getFluentEnumGetterMethodName() {
205         return fluentEnumGetterMethodName;
206     }
207 
setFluentEnumGetterMethodName(String fluentEnumGetterMethodName)208     public void setFluentEnumGetterMethodName(String fluentEnumGetterMethodName) {
209         this.fluentEnumGetterMethodName = fluentEnumGetterMethodName;
210     }
211 
withFluentEnumGetterMethodName(String fluentEnumGetterMethodName)212     public MemberModel withFluentEnumGetterMethodName(String fluentEnumGetterMethodName) {
213         setFluentEnumGetterMethodName(fluentEnumGetterMethodName);
214         return this;
215     }
216 
getBeanStyleGetterMethodName()217     public String getBeanStyleGetterMethodName() {
218         return beanStyleGetterName;
219     }
220 
setBeanStyleGetterMethodName(String beanStyleGetterName)221     public void setBeanStyleGetterMethodName(String beanStyleGetterName) {
222         this.beanStyleGetterName = beanStyleGetterName;
223     }
224 
withBeanStyleGetterMethodName(String beanStyleGetterName)225     public MemberModel withBeanStyleGetterMethodName(String beanStyleGetterName) {
226         this.beanStyleGetterName = beanStyleGetterName;
227         return this;
228     }
229 
getBeanStyleSetterMethodName()230     public String getBeanStyleSetterMethodName() {
231         return beanStyleSetterName;
232     }
233 
setBeanStyleSetterMethodName(String beanStyleSetterName)234     public void setBeanStyleSetterMethodName(String beanStyleSetterName) {
235         this.beanStyleSetterName = beanStyleSetterName;
236     }
237 
withBeanStyleSetterMethodName(String beanStyleSetterName)238     public MemberModel withBeanStyleSetterMethodName(String beanStyleSetterName) {
239         this.beanStyleSetterName = beanStyleSetterName;
240         return this;
241     }
242 
getFluentSetterMethodName()243     public String getFluentSetterMethodName() {
244         return fluentSetterMethodName;
245     }
246 
setFluentSetterMethodName(String fluentSetterMethodName)247     public void setFluentSetterMethodName(String fluentSetterMethodName) {
248         this.fluentSetterMethodName = fluentSetterMethodName;
249     }
250 
withFluentSetterMethodName(String fluentMethodName)251     public MemberModel withFluentSetterMethodName(String fluentMethodName) {
252         setFluentSetterMethodName(fluentMethodName);
253         return this;
254     }
255 
getFluentEnumSetterMethodName()256     public String getFluentEnumSetterMethodName() {
257         return fluentEnumSetterMethodName;
258     }
259 
setFluentEnumSetterMethodName(String fluentEnumSetterMethodName)260     public void setFluentEnumSetterMethodName(String fluentEnumSetterMethodName) {
261         this.fluentEnumSetterMethodName = fluentEnumSetterMethodName;
262     }
263 
withFluentEnumSetterMethodName(String fluentEnumSetterMethodName)264     public MemberModel withFluentEnumSetterMethodName(String fluentEnumSetterMethodName) {
265         setFluentEnumSetterMethodName(fluentEnumSetterMethodName);
266         return this;
267     }
268 
getExistenceCheckMethodName()269     public String getExistenceCheckMethodName() {
270         return existenceCheckMethodName;
271     }
272 
setExistenceCheckMethodName(String existenceCheckMethodName)273     public void setExistenceCheckMethodName(String existenceCheckMethodName) {
274         this.existenceCheckMethodName = existenceCheckMethodName;
275     }
276 
withExistenceCheckMethodName(String existenceCheckMethodName)277     public MemberModel withExistenceCheckMethodName(String existenceCheckMethodName) {
278         setExistenceCheckMethodName(existenceCheckMethodName);
279         return this;
280     }
281 
getGetterModel()282     public ReturnTypeModel getGetterModel() {
283         return getterModel;
284     }
285 
setGetterModel(ReturnTypeModel getterModel)286     public void setGetterModel(ReturnTypeModel getterModel) {
287         this.getterModel = getterModel;
288     }
289 
withGetterModel(ReturnTypeModel getterModel)290     public MemberModel withGetterModel(ReturnTypeModel getterModel) {
291         setGetterModel(getterModel);
292         return this;
293     }
294 
getHttp()295     public ParameterHttpMapping getHttp() {
296         return http;
297     }
298 
setHttp(ParameterHttpMapping parameterHttpMapping)299     public void setHttp(ParameterHttpMapping parameterHttpMapping) {
300         this.http = parameterHttpMapping;
301     }
302 
isSimple()303     public boolean isSimple() {
304         return TypeUtils.isSimple(variable.getVariableType());
305     }
306 
isList()307     public boolean isList() {
308         return listModel != null;
309     }
310 
isMap()311     public boolean isMap() {
312         return mapModel != null;
313     }
314 
isDeprecated()315     public boolean isDeprecated() {
316         return deprecated;
317     }
318 
setDeprecated(boolean deprecated)319     public void setDeprecated(boolean deprecated) {
320         this.deprecated = deprecated;
321     }
322 
getDeprecatedMessage()323     public String getDeprecatedMessage() {
324         return deprecatedMessage;
325     }
326 
setDeprecatedMessage(String deprecatedMessage)327     public void setDeprecatedMessage(String deprecatedMessage) {
328         this.deprecatedMessage = deprecatedMessage;
329     }
330 
isRequired()331     public boolean isRequired() {
332         return required;
333     }
334 
setRequired(boolean required)335     public void setRequired(boolean required) {
336         this.required = required;
337     }
338 
isEventPayload()339     public boolean isEventPayload() {
340         return eventPayload;
341     }
342 
setEventPayload(boolean eventPayload)343     public void setEventPayload(boolean eventPayload) {
344         this.eventPayload = eventPayload;
345     }
346 
isEventHeader()347     public boolean isEventHeader() {
348         return eventHeader;
349     }
350 
setEventHeader(boolean eventHeader)351     public void setEventHeader(boolean eventHeader) {
352         this.eventHeader = eventHeader;
353     }
354 
355 
isEndpointDiscoveryId()356     public boolean isEndpointDiscoveryId() {
357         return endpointDiscoveryId;
358     }
359 
setEndpointDiscoveryId(boolean endpointDiscoveryId)360     public void setEndpointDiscoveryId(boolean endpointDiscoveryId) {
361         this.endpointDiscoveryId = endpointDiscoveryId;
362     }
363 
getListModel()364     public ListModel getListModel() {
365         return listModel;
366     }
367 
setListModel(ListModel listModel)368     public void setListModel(ListModel listModel) {
369         this.listModel = listModel;
370     }
371 
withListModel(ListModel list)372     public MemberModel withListModel(ListModel list) {
373         setListModel(list);
374         return this;
375     }
376 
getMapModel()377     public MapModel getMapModel() {
378         return mapModel;
379     }
380 
setMapModel(MapModel map)381     public void setMapModel(MapModel map) {
382         this.mapModel = map;
383     }
384 
withMapModel(MapModel map)385     public MemberModel withMapModel(MapModel map) {
386         setMapModel(map);
387         return this;
388     }
389 
getEnumType()390     public String getEnumType() {
391         return enumType;
392     }
393 
setEnumType(String enumType)394     public void setEnumType(String enumType) {
395         this.enumType = enumType;
396     }
397 
withEnumType(String enumType)398     public MemberModel withEnumType(String enumType) {
399         setEnumType(enumType);
400         return this;
401     }
402 
getXmlNameSpaceUri()403     public String getXmlNameSpaceUri() {
404         return xmlNameSpaceUri;
405     }
406 
setXmlNameSpaceUri(String xmlNameSpaceUri)407     public void setXmlNameSpaceUri(String xmlNameSpaceUri) {
408         this.xmlNameSpaceUri = xmlNameSpaceUri;
409     }
410 
withXmlNameSpaceUri(String xmlNameSpaceUri)411     public MemberModel withXmlNameSpaceUri(String xmlNameSpaceUri) {
412         setXmlNameSpaceUri(xmlNameSpaceUri);
413         return this;
414     }
415 
getSetterDocumentation()416     public String getSetterDocumentation() {
417         StringBuilder docBuilder = new StringBuilder();
418 
419         docBuilder.append(StringUtils.isNotBlank(documentation) ? documentation : defaultSetter().replace("%s", name) + "\n");
420 
421         docBuilder.append(getParamDoc())
422                 .append(getEnumDoc());
423 
424         return docBuilder.toString();
425     }
426 
getGetterDocumentation()427     public String getGetterDocumentation() {
428         StringBuilder docBuilder = new StringBuilder();
429         docBuilder.append(StringUtils.isNotBlank(documentation) ? documentation : defaultGetter().replace("%s", name))
430                 .append(LF);
431 
432         if (returnTypeIs(List.class) || returnTypeIs(Map.class)) {
433             appendParagraph(docBuilder, "Attempts to modify the collection returned by this method will result in an "
434                                         + "UnsupportedOperationException.");
435         }
436 
437         if (enumType != null) {
438             if (returnTypeIs(List.class)) {
439                 appendParagraph(docBuilder,
440                                 "If the list returned by the service includes enum values that are not available in the "
441                                 + "current SDK version, {@link #%s} will use {@link %s#UNKNOWN_TO_SDK_VERSION} in place of those "
442                                 + "values in the list. The raw values returned by the service are available from {@link #%s}.",
443                                 getFluentEnumGetterMethodName(), getEnumType(), getFluentGetterMethodName());
444             } else if (returnTypeIs(Map.class)) {
445                 appendParagraph(docBuilder,
446                                 "If the map returned by the service includes enum values that are not available in the "
447                                 + "current SDK version, {@link #%s} will not include those keys in the map. {@link #%s} "
448                                 + "will include all data from the service.",
449                                 getFluentEnumGetterMethodName(), getEnumType(), getFluentGetterMethodName());
450             } else {
451                 appendParagraph(docBuilder,
452                                 "If the service returns an enum value that is not available in the current SDK version, "
453                                 + "{@link #%s} will return {@link %s#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the "
454                                 + "service is available from {@link #%s}.",
455                                 getFluentEnumGetterMethodName(), getEnumType(), getFluentGetterMethodName());
456             }
457         }
458 
459         if (getAutoConstructClassIfExists().isPresent()) {
460             appendParagraph(docBuilder,
461                             "This method will never return null. If you would like to know whether the service returned this "
462                             + "field (so that you can differentiate between null and empty), you can use the {@link #%s} method.",
463                             getExistenceCheckMethodName());
464         }
465 
466         String variableDesc = StringUtils.isNotBlank(documentation) ? documentation : defaultGetterParam().replace("%s", name);
467 
468         docBuilder.append("@return ")
469                   .append(stripHtmlTags(variableDesc))
470                   .append(getEnumDoc());
471 
472         return docBuilder.toString();
473     }
474 
getDeprecatedGetterDocumentation()475     public String getDeprecatedGetterDocumentation() {
476         String getterDocumentation = getGetterDocumentation();
477         return getterDocumentation
478                + LF
479                + "@deprecated Use {@link #" + getFluentGetterMethodName() + "()}"
480                + LF;
481     }
482 
returnTypeIs(Class<?> clazz)483     private boolean returnTypeIs(Class<?> clazz) {
484         String returnType = this.getGetterModel().getReturnType();
485         return returnType != null && returnType.startsWith(clazz.getName()); // Use startsWith in case it's parametrized
486     }
487 
getFluentSetterDocumentation()488     public String getFluentSetterDocumentation() {
489         return getSetterDocumentation()
490                + LF
491                + "@return " + stripHtmlTags(defaultFluentReturn())
492                + getEnumDoc();
493     }
494 
getExistenceCheckDocumentation()495     public String getExistenceCheckDocumentation() {
496         return defaultExistenceCheck().replace("%s", name) + LF;
497     }
498 
getDeprecatedSetterDocumentation()499     public String getDeprecatedSetterDocumentation() {
500         return getFluentSetterDocumentation()
501             + LF
502             + "@deprecated Use {@link #" + getFluentSetterMethodName() + "(" + setterModel.getSimpleType() + ")}"
503             + LF;
504     }
505 
getDefaultConsumerFluentSetterDocumentation(String variableType)506     public String getDefaultConsumerFluentSetterDocumentation(String variableType) {
507         return (StringUtils.isNotBlank(documentation) ? documentation : defaultSetter().replace("%s", name) + "\n")
508                + LF
509                + "This is a convenience method that creates an instance of the {@link "
510                + variableType
511                + ".Builder} avoiding the need to create one manually via {@link "
512                + variableType
513                + "#builder()}.\n"
514                + LF
515                + "<p>"
516                + "When the {@link Consumer} completes, {@link "
517                + variableType
518                + ".Builder#build()} is called immediately and its result is passed to {@link #"
519                + getFluentGetterMethodName()
520                + "("
521                + variable.getSimpleType()
522                + ")}."
523                + LF
524                + "@param "
525                + variable.getVariableName()
526                + " a consumer that will call methods on {@link "
527                + variableType + ".Builder}"
528                + LF
529                + "@return " + stripHtmlTags(defaultFluentReturn())
530                + LF
531                + "@see #"
532                + getFluentSetterMethodName()
533                + "("
534                + variable.getVariableSetterType()
535                + ")";
536     }
537 
getUnionConstructorDocumentation()538     public String getUnionConstructorDocumentation() {
539         return "Create an instance of this class with {@link #" + this.getFluentGetterMethodName() +
540                "()} initialized to the given value." +
541                LF + LF +
542                getSetterDocumentation();
543     }
544 
getParamDoc()545     private String getParamDoc() {
546         return LF
547                + "@param "
548                + variable.getVariableName()
549                + " "
550                + stripHtmlTags(StringUtils.isNotBlank(documentation) ? documentation : defaultSetterParam().replace("%s", name));
551     }
552 
getEnumDoc()553     private String getEnumDoc() {
554         StringBuilder docBuilder = new StringBuilder();
555 
556         if (enumType != null) {
557             docBuilder.append(LF).append("@see ").append(enumType);
558         }
559 
560         return docBuilder.toString();
561     }
562 
isIdempotencyToken()563     public boolean isIdempotencyToken() {
564         return idempotencyToken;
565     }
566 
setIdempotencyToken(boolean idempotencyToken)567     public void setIdempotencyToken(boolean idempotencyToken) {
568         this.idempotencyToken = idempotencyToken;
569     }
570 
getIsBinary()571     public boolean getIsBinary() {
572         return http.getIsStreaming() ||
573                (isSdkBytesType() && (http.getIsPayload() || isEventPayload()));
574     }
575 
576     /**
577      * @return Implementation of {@link PathMarshaller} to use if this member is bound the the URI.
578      * @throws IllegalStateException If this member is not bound to the URI. Templates should first check
579      * {@link ParameterHttpMapping#isUri()} first.
580      */
581     // TODO remove when rest XML marshaller refactor is merged
582     @JsonIgnore
getPathMarshaller()583     public String getPathMarshaller() {
584         if (!http.isUri()) {
585             throw new IllegalStateException("Only members bound to the URI have a path marshaller");
586         }
587         String prefix = PathMarshaller.class.getName();
588         if (http.isGreedy()) {
589             return prefix + ".GREEDY";
590         } else if (isIdempotencyToken()) {
591             return prefix + ".IDEMPOTENCY";
592         } else {
593             return prefix + ".NON_GREEDY";
594         }
595     }
596 
isJsonValue()597     public boolean isJsonValue() {
598         return isJsonValue;
599     }
600 
setJsonValue(boolean jsonValue)601     public void setJsonValue(boolean jsonValue) {
602         isJsonValue = jsonValue;
603     }
604 
withJsonValue(boolean jsonValue)605     public MemberModel withJsonValue(boolean jsonValue) {
606         setJsonValue(jsonValue);
607         return this;
608     }
609 
getTimestampFormat()610     public String getTimestampFormat() {
611         return timestampFormat;
612     }
613 
setTimestampFormat(String timestampFormat)614     public void setTimestampFormat(String timestampFormat) {
615         this.timestampFormat = timestampFormat;
616     }
617 
withTimestampFormat(String timestampFormat)618     public MemberModel withTimestampFormat(String timestampFormat) {
619         setTimestampFormat(timestampFormat);
620         return this;
621     }
622 
setSensitive(boolean sensitive)623     public void setSensitive(boolean sensitive) {
624         this.sensitive = sensitive;
625     }
626 
isSensitive()627     public boolean isSensitive() {
628         return sensitive;
629     }
630 
isXmlAttribute()631     public boolean isXmlAttribute() {
632         return xmlAttribute;
633     }
634 
setXmlAttribute(boolean xmlAttribute)635     public void setXmlAttribute(boolean xmlAttribute) {
636         this.xmlAttribute = xmlAttribute;
637     }
638 
withXmlAttribtue(boolean xmlAttribtue)639     public MemberModel withXmlAttribtue(boolean xmlAttribtue) {
640         this.xmlAttribute = xmlAttribtue;
641         return this;
642     }
643 
getDeprecatedName()644     public String getDeprecatedName() {
645         return deprecatedName;
646     }
647 
setDeprecatedName(String deprecatedName)648     public void setDeprecatedName(String deprecatedName) {
649         this.deprecatedName = deprecatedName;
650     }
651 
withDeprecatedName(String deprecatedName)652     public MemberModel withDeprecatedName(String deprecatedName) {
653         this.deprecatedName = deprecatedName;
654         return this;
655     }
656 
657     @JsonIgnore
hasBuilder()658     public boolean hasBuilder() {
659         return !(isSimple() || isList() || isMap());
660     }
661 
662     @JsonIgnore
containsBuildable()663     public boolean containsBuildable() {
664         return containsBuildable(true);
665     }
666 
containsBuildable(boolean root)667     private boolean containsBuildable(boolean root) {
668         if (!root && hasBuilder()) {
669             return true;
670         }
671 
672         if (isList()) {
673             return getListModel().getListMemberModel().containsBuildable(false);
674         }
675 
676         if (isMap()) {
677             MapModel mapModel = getMapModel();
678             return mapModel.getKeyModel().containsBuildable(false) ||
679                    mapModel.getValueModel().containsBuildable(false);
680         }
681 
682         return false;
683     }
684 
685     @JsonIgnore
isSdkBytesType()686     public boolean isSdkBytesType() {
687         return SdkBytes.class.getName().equals(variable.getVariableType());
688     }
689 
690     /**
691      * @return Marshalling type to use when creating a {@link SdkField}. Must be a
692      * field of {@link MarshallingType}.
693      */
getMarshallingType()694     public String getMarshallingType() {
695         if (isList()) {
696             return "LIST";
697         } else if (isMap()) {
698             return "MAP";
699         } else if (!isSimple()) {
700             return "SDK_POJO";
701         } else {
702             return TypeUtils.getMarshallingType(variable.getSimpleType());
703         }
704     }
705 
706     @JsonIgnore
getShape()707     public ShapeModel getShape() {
708         return shape;
709     }
710 
setShape(ShapeModel shape)711     public void setShape(ShapeModel shape) {
712         this.shape = shape;
713     }
714 
715     @Override
toString()716     public String toString() {
717         return c2jName;
718     }
719 
appendParagraph(StringBuilder builder, String content, Object... contentArgs)720     private void appendParagraph(StringBuilder builder, String content, Object... contentArgs) {
721         builder.append("<p>")
722                .append(LF)
723                .append(String.format(content, contentArgs))
724                .append(LF)
725                .append("</p>")
726                .append(LF);
727     }
728 
getAutoConstructClassIfExists()729     public Optional<ClassName> getAutoConstructClassIfExists() {
730         if (isList()) {
731             return Optional.of(ClassName.get(SdkAutoConstructList.class));
732         } else if (isMap()) {
733             return Optional.of(ClassName.get(SdkAutoConstructMap.class));
734         }
735 
736         return Optional.empty();
737     }
738 
setDeprecatedFluentGetterMethodName(String fluentDeprecatedGetterMethodName)739     public void setDeprecatedFluentGetterMethodName(String fluentDeprecatedGetterMethodName) {
740         this.fluentDeprecatedGetterMethodName = fluentDeprecatedGetterMethodName;
741     }
742 
getDeprecatedFluentGetterMethodName()743     public String getDeprecatedFluentGetterMethodName() {
744         return fluentDeprecatedGetterMethodName;
745     }
746 
setDeprecatedFluentSetterMethodName(String fluentDeprecatedSetterMethodName)747     public void setDeprecatedFluentSetterMethodName(String fluentDeprecatedSetterMethodName) {
748         this.fluentDeprecatedSetterMethodName = fluentDeprecatedSetterMethodName;
749     }
750 
getDeprecatedFluentSetterMethodName()751     public String getDeprecatedFluentSetterMethodName() {
752         return fluentDeprecatedSetterMethodName;
753     }
754 
getDeprecatedBeanStyleSetterMethodName()755     public String getDeprecatedBeanStyleSetterMethodName() {
756         return deprecatedBeanStyleSetterMethodName;
757     }
758 
setDeprecatedBeanStyleSetterMethodName(String deprecatedBeanStyleSetterMethodName)759     public void setDeprecatedBeanStyleSetterMethodName(String deprecatedBeanStyleSetterMethodName) {
760         this.deprecatedBeanStyleSetterMethodName = deprecatedBeanStyleSetterMethodName;
761     }
762 
getUnionEnumTypeName()763     public String getUnionEnumTypeName() {
764         return unionEnumTypeName;
765     }
766 
setUnionEnumTypeName(String unionEnumTypeName)767     public void setUnionEnumTypeName(String unionEnumTypeName) {
768         this.unionEnumTypeName = unionEnumTypeName;
769     }
770 
getContextParam()771     public ContextParam getContextParam() {
772         return contextParam;
773     }
774 
setContextParam(ContextParam contextParam)775     public void setContextParam(ContextParam contextParam) {
776         this.contextParam = contextParam;
777     }
778 }
779