1
15 package com.amazonaws.partitions.model;
16
17 import com.amazonaws.Protocol;
18 import com.fasterxml.jackson.annotation.JsonProperty;
19
20 import java.util.Set;
21
22
25 public class Endpoint {
26
27
30 private String hostName;
31
32
35 private CredentialScope credentialScope;
36
37
40 private Set<String> protocols;
41
42
45 private Set<String> signatureVersions;
46
47
50 private String sslCommonName;
51
52
55 public static Endpoint merge(Endpoint defaults, Endpoint override) {
56
57 if (defaults == null) {
58 defaults = new Endpoint();
59 }
60
61 if (override == null) {
62 override = new Endpoint();
63 }
64
65 final Endpoint merged = new Endpoint();
66
67 merged.setCredentialScope(override.getCredentialScope() != null
68 ? override.getCredentialScope()
69 : defaults.getCredentialScope());
70
71 merged.setHostName(override.getHostName() != null
72 ? override.getHostName()
73 : defaults.getHostName());
74
75 merged.setSslCommonName(override.getSslCommonName() != null
76 ? override.getSslCommonName()
77 : defaults.getSslCommonName());
78
79 merged.setProtocols(override.getProtocols() != null
80 ? override.getProtocols()
81 : defaults.getProtocols());
82
83 merged.setSignatureVersions(override.getSignatureVersions() != null
84 ? override.getSignatureVersions()
85 : defaults.getSignatureVersions()
86 );
87
88 return merged;
89
90 }
91
92
95 public String getHostName() {
96 return hostName;
97 }
98
99
102 @JsonProperty(value = "hostname")
103 public void setHostName(String hostName) {
104 this.hostName = hostName;
105 }
106
107
110 public CredentialScope getCredentialScope() {
111 return credentialScope;
112 }
113
114
117 @JsonProperty(value = "credentialScope")
118 public void setCredentialScope(CredentialScope credentialScope) {
119 this.credentialScope = credentialScope;
120 }
121
122
125 public Set<String> getProtocols() {
126 return protocols;
127 }
128
129
132 @JsonProperty(value = "protocols")
133 public void setProtocols(Set<String> protocols) {
134 this.protocols = protocols;
135 }
136
137
140 public Set<String> getSignatureVersions() {
141 return signatureVersions;
142 }
143
144
147 @JsonProperty(value = "signatureVersions")
148 public void setSignatureVersions(Set<String> signatureVersions) {
149 this.signatureVersions = signatureVersions;
150 }
151
152
155 public String getSslCommonName() {
156 return sslCommonName;
157 }
158
159
162 @JsonProperty(value = "sslCommonName")
163 public void setSslCommonName(String sslCommonName) {
164 this.sslCommonName = sslCommonName;
165 }
166
167
171 public boolean hasHttpsSupport() {
172 return isProtocolSupported(Protocol.HTTPS);
173 }
174
175
179 public boolean hasHttpSupport() {
180 return isProtocolSupported(Protocol.HTTP);
181 }
182
183 private boolean isProtocolSupported(Protocol protocol) {
184 return protocols != null && protocols.contains(protocol.toString());
185 }
186
187 }
188