1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.jclouds.savvis.vpdc.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 org.jclouds.javax.annotation.Nullable;
27
28 import com.google.common.base.CaseFormat;
29 import com.google.common.collect.ImmutableSet;
30 import com.google.common.collect.Sets;
31
32
33
34
35
36
37 public class VDC extends ResourceImpl {
38 public static Builder builder() {
39 return new Builder();
40 }
41
42 public static class Builder extends ResourceImpl.Builder {
43 private String description;
44 private Status status;
45 private Set<Resource> resourceEntities = Sets.newLinkedHashSet();
46 private Set<Resource> availableNetworks = Sets.newLinkedHashSet();
47
48 public Builder description(String description) {
49 this.description = description;
50 return this;
51 }
52
53 public Builder status(Status status) {
54 this.status = status;
55 return this;
56 }
57
58 public Builder resourceEntity(Resource resourceEntity) {
59 this.resourceEntities.add(checkNotNull(resourceEntity, "resourceEntity"));
60 return this;
61 }
62
63 public Builder resourceEntities(Set<Resource> resourceEntities) {
64 this.resourceEntities.addAll(checkNotNull(resourceEntities, "resourceEntities"));
65 return this;
66 }
67
68 public Builder availableNetwork(Resource availableNetwork) {
69 this.availableNetworks.add(checkNotNull(availableNetwork, "availableNetwork"));
70 return this;
71 }
72
73 public Builder availableNetworks(Set<Resource> availableNetworks) {
74 this.availableNetworks.addAll(checkNotNull(availableNetworks, "availableNetworks"));
75 return this;
76 }
77
78 @Override
79 public VDC build() {
80 return new VDC(id, name, type, href, description, status, resourceEntities, availableNetworks);
81 }
82
83 public static Builder fromVDC(VDC in) {
84 return new Builder().id(in.getId()).name(in.getName()).type(in.getType()).href(in.getHref())
85 .status(in.getStatus()).description(in.getDescription()).availableNetworks(in.getAvailableNetworks())
86 .resourceEntities(in.getResourceEntities());
87 }
88
89 @Override
90 public Builder id(String id) {
91 return Builder.class.cast(super.id(id));
92 }
93
94 @Override
95 public Builder name(String name) {
96 return Builder.class.cast(super.name(name));
97 }
98
99 @Override
100 public Builder type(String type) {
101 return Builder.class.cast(super.type(type));
102 }
103
104 @Override
105 public Builder href(URI href) {
106 return Builder.class.cast(super.href(href));
107 }
108
109 }
110
111 public enum Status {
112
113
114
115 DEPLOYED,
116
117
118
119
120 DESIGNING,
121
122
123
124
125 SAVED,
126
127
128
129
130 INQUEUE,
131
132
133
134
135 PROVISIONING,
136
137
138
139
140
141 PARTIALLY_DEPLOYED,
142
143
144
145
146
147 FAILED, UNRECOGNIZED;
148 @Override
149 public String toString() {
150 return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name());
151 }
152
153 public static Status fromValue(String status) {
154 try {
155 return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(status, "status")));
156 } catch (IllegalArgumentException e) {
157 return UNRECOGNIZED;
158 }
159 }
160 }
161
162 @Nullable
163 private final String description;
164 private final VDC.Status status;
165 private final Set<Resource> resourceEntities;
166 private final Set<Resource> availableNetworks;
167
168 public VDC(String id, String name, String type, URI href, @Nullable String description, VDC.Status status,
169 Set<Resource> resourceEntities, Set<Resource> availableNetworks) {
170 super(id, name, type, href);
171 this.description = description;
172 this.status = checkNotNull(status, "status");
173 this.resourceEntities = ImmutableSet.copyOf(checkNotNull(resourceEntities, "resourceEntities"));
174 this.availableNetworks = ImmutableSet.copyOf(checkNotNull(availableNetworks, "availableNetworks"));
175 }
176
177
178
179
180 public String getDescription() {
181 return description;
182 }
183
184
185
186
187 public VDC.Status getStatus() {
188 return status;
189 }
190
191
192
193
194 public Set<Resource> getResourceEntities() {
195 return resourceEntities;
196 }
197
198
199
200
201 public Set<Resource> getAvailableNetworks() {
202 return availableNetworks;
203 }
204
205 @Override
206 public Builder toBuilder() {
207 return Builder.fromVDC(this);
208 }
209
210 @Override
211 public String toString() {
212 return "[id=" + id + ", href=" + href + ", name=" + name + ", type=" + type + ", description=" + description
213 + ", status=" + status + ", resourceEntities=" + resourceEntities + ", availableNetworks="
214 + availableNetworks + "]";
215 }
216
217 }