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.core.traits;
17
18 import software.amazon.awssdk.annotations.SdkProtectedApi;
19 import software.amazon.awssdk.core.SdkField;
20
21 /**
22  * Trait that includes additional metadata for Map members.
23  */

24 @SdkProtectedApi
25 public final class MapTrait implements Trait {
26
27     private final String keyLocationName;
28     private final String valueLocationName;
29     private final SdkField valueFieldInfo;
30     private final boolean isFlattened;
31
32     private MapTrait(Builder builder) {
33         this.keyLocationName = builder.keyLocationName;
34         this.valueLocationName = builder.valueLocationName;
35         this.valueFieldInfo = builder.valueFieldInfo;
36         this.isFlattened = builder.isFlattened;
37     }
38
39     /**
40      * @return Location name of key. Used only for XML based protocols.
41      */

42     public String keyLocationName() {
43         return keyLocationName;
44     }
45
46     /**
47      * @return Location name of value. Used only for XML based protocols.
48      */

49     public String valueLocationName() {
50         return valueLocationName;
51     }
52
53     /**
54      * @return Additional metadata for the map value types. May be further nested in the case of complex containers.
55      */

56     public SdkField valueFieldInfo() {
57         return valueFieldInfo;
58     }
59
60     /**
61      * @return Whether the map should be marshalled/unmarshalled as a 'flattened' map. This only applies to Query/XML protocols.
62      */

63     public boolean isFlattened() {
64         return isFlattened;
65     }
66
67     public static Builder builder() {
68         return new Builder();
69     }
70
71     public static final class Builder {
72
73         private String keyLocationName;
74         private String valueLocationName;
75         private SdkField valueFieldInfo;
76         private boolean isFlattened;
77
78         private Builder() {
79         }
80
81         public Builder keyLocationName(String keyLocationName) {
82             this.keyLocationName = keyLocationName;
83             return this;
84         }
85
86         public Builder valueLocationName(String valueLocationName) {
87             this.valueLocationName = valueLocationName;
88             return this;
89         }
90
91         public Builder valueFieldInfo(SdkField valueFieldInfo) {
92             this.valueFieldInfo = valueFieldInfo;
93             return this;
94         }
95
96         public Builder isFlattened(boolean isFlattened) {
97             this.isFlattened = isFlattened;
98             return this;
99         }
100
101         public MapTrait build() {
102             return new MapTrait(this);
103         }
104     }
105 }
106