1
15
16 package software.amazon.awssdk.protocols.xml.internal.marshall;
17
18 import software.amazon.awssdk.annotations.SdkInternalApi;
19 import software.amazon.awssdk.core.protocol.MarshallLocation;
20 import software.amazon.awssdk.core.protocol.MarshallingType;
21 import software.amazon.awssdk.protocols.core.AbstractMarshallingRegistry;
22
23 @SdkInternalApi
24 public final class XmlMarshallerRegistry extends AbstractMarshallingRegistry {
25
26 private XmlMarshallerRegistry(Builder builder) {
27 super(builder);
28 }
29
30 @SuppressWarnings("unchecked")
31 public <T> XmlMarshaller<T> getMarshaller(MarshallLocation marshallLocation, T val) {
32 return (XmlMarshaller<T>) get(marshallLocation, toMarshallingType(val));
33 }
34
35 @SuppressWarnings("unchecked")
36 public <T> XmlMarshaller<Object> getMarshaller(MarshallLocation marshallLocation,
37 MarshallingType<T> marshallingType,
38 Object val) {
39 return (XmlMarshaller<Object>) get(marshallLocation,
40 val == null ? MarshallingType.NULL : marshallingType);
41 }
42
43
46 public static Builder builder() {
47 return new Builder();
48 }
49
50
53 public static final class Builder extends AbstractMarshallingRegistry.Builder {
54 private Builder() {
55 }
56
57 public <T> Builder payloadMarshaller(MarshallingType<T> marshallingType,
58 XmlMarshaller<T> marshaller) {
59 register(MarshallLocation.PAYLOAD, marshallingType, marshaller);
60 return this;
61 }
62
63 public <T> Builder headerMarshaller(MarshallingType<T> marshallingType,
64 XmlMarshaller<T> marshaller) {
65 register(MarshallLocation.HEADER, marshallingType, marshaller);
66 return this;
67 }
68
69 public <T> Builder queryParamMarshaller(MarshallingType<T> marshallingType,
70 XmlMarshaller<T> marshaller) {
71 register(MarshallLocation.QUERY_PARAM, marshallingType, marshaller);
72 return this;
73 }
74
75 public <T> Builder pathParamMarshaller(MarshallingType<T> marshallingType,
76 XmlMarshaller<T> marshaller) {
77 register(MarshallLocation.PATH, marshallingType, marshaller);
78 return this;
79 }
80
81 public <T> Builder greedyPathParamMarshaller(MarshallingType<T> marshallingType,
82 XmlMarshaller<T> marshaller) {
83 register(MarshallLocation.GREEDY_PATH, marshallingType, marshaller);
84 return this;
85 }
86
87
90 public XmlMarshallerRegistry build() {
91 return new XmlMarshallerRegistry(this);
92 }
93 }
94 }
95