1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.jclouds.vcloud.domain;
20
21 import static com.google.common.base.Preconditions.checkNotNull;
22
23 import java.net.URI;
24 import java.util.Set;
25
26 import com.google.common.collect.ImmutableSet;
27
28
29
30
31
32
33
34
35
36 public class NetworkConnectionSection {
37 public static Builder builder() {
38 return new Builder();
39 }
40
41 public static class Builder {
42 protected String type;
43 protected URI href;
44 protected String info;
45 protected Integer primaryNetworkConnectionIndex;
46 protected Set<NetworkConnection> connections = ImmutableSet.of();
47 protected ReferenceType edit;
48
49 public Builder type(String type) {
50 this.type = type;
51 return this;
52 }
53
54 public Builder href(URI href) {
55 this.href = href;
56 return this;
57 }
58
59 public Builder info(String info) {
60 this.info = info;
61 return this;
62 }
63
64 public Builder primaryNetworkConnectionIndex(Integer primaryNetworkConnectionIndex) {
65 this.primaryNetworkConnectionIndex = primaryNetworkConnectionIndex;
66 return this;
67 }
68
69 public Builder connections(Iterable<? extends NetworkConnection> connections) {
70 this.connections = ImmutableSet.copyOf(checkNotNull(connections, "connections"));
71 return this;
72 }
73
74 public Builder edit(ReferenceType edit) {
75 this.edit = edit;
76 return this;
77 }
78
79 public NetworkConnectionSection build() {
80 return new NetworkConnectionSection(type, href, info, primaryNetworkConnectionIndex, connections, edit);
81 }
82
83 public static Builder fromNetworkConnectionSection(NetworkConnectionSection in) {
84 return new Builder().type(in.getType()).href(in.getHref()).info(in.getInfo())
85 .primaryNetworkConnectionIndex(in.getPrimaryNetworkConnectionIndex()).connections(in.getConnections())
86 .edit(in.getEdit());
87 }
88 }
89
90 protected final String type;
91 protected final URI href;
92 protected final String info;
93 protected final Integer primaryNetworkConnectionIndex;
94 protected final Set<NetworkConnection> connections;
95 protected final ReferenceType edit;
96
97 public NetworkConnectionSection(String type, URI href, String info, Integer primaryNetworkConnectionIndex,
98 Iterable<NetworkConnection> connections, ReferenceType edit) {
99 this.type = type;
100 this.href = href;
101 this.info = info;
102 this.primaryNetworkConnectionIndex = primaryNetworkConnectionIndex;
103 this.connections = ImmutableSet.copyOf(checkNotNull(connections, "connections"));
104 this.edit = edit;
105 }
106
107
108
109
110
111 public String getType() {
112 return type;
113 }
114
115
116
117
118
119 public URI getHref() {
120 return href;
121 }
122
123
124
125
126
127 public String getInfo() {
128 return info;
129 }
130
131
132
133
134
135
136 public Integer getPrimaryNetworkConnectionIndex() {
137 return primaryNetworkConnectionIndex;
138 }
139
140
141
142
143 public Set<? extends NetworkConnection> getConnections() {
144 return connections;
145 }
146
147
148
149
150 public ReferenceType getEdit() {
151 return edit;
152 }
153
154 @Override
155 public int hashCode() {
156 final int prime = 31;
157 int result = 1;
158 result = prime * result + ((connections == null) ? 0 : connections.hashCode());
159 result = prime * result + ((edit == null) ? 0 : edit.hashCode());
160 result = prime * result + ((href == null) ? 0 : href.hashCode());
161 result = prime * result + ((info == null) ? 0 : info.hashCode());
162 result = prime * result
163 + ((primaryNetworkConnectionIndex == null) ? 0 : primaryNetworkConnectionIndex.hashCode());
164 result = prime * result + ((type == null) ? 0 : type.hashCode());
165 return result;
166 }
167
168 @Override
169 public boolean equals(Object obj) {
170 if (this == obj)
171 return true;
172 if (obj == null)
173 return false;
174 if (getClass() != obj.getClass())
175 return false;
176 NetworkConnectionSection other = (NetworkConnectionSection) obj;
177 if (connections == null) {
178 if (other.connections != null)
179 return false;
180 } else if (!connections.equals(other.connections))
181 return false;
182 if (edit == null) {
183 if (other.edit != null)
184 return false;
185 } else if (!edit.equals(other.edit))
186 return false;
187 if (href == null) {
188 if (other.href != null)
189 return false;
190 } else if (!href.equals(other.href))
191 return false;
192 if (info == null) {
193 if (other.info != null)
194 return false;
195 } else if (!info.equals(other.info))
196 return false;
197 if (primaryNetworkConnectionIndex == null) {
198 if (other.primaryNetworkConnectionIndex != null)
199 return false;
200 } else if (!primaryNetworkConnectionIndex.equals(other.primaryNetworkConnectionIndex))
201 return false;
202 if (type == null) {
203 if (other.type != null)
204 return false;
205 } else if (!type.equals(other.type))
206 return false;
207 return true;
208 }
209
210 public Builder toBuilder() {
211 return Builder.fromNetworkConnectionSection(this);
212 }
213
214 @Override
215 public String toString() {
216 return "[href=" + href + ", connections=" + connections + ", primaryNetworkConnectionIndex="
217 + primaryNetworkConnectionIndex + "]";
218 }
219
220 }