1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.jclouds.cloudsigma.domain;
20
21 import static com.google.common.base.Preconditions.checkNotNull;
22
23 import java.util.Set;
24
25 import javax.annotation.Nullable;
26
27 import com.google.common.collect.ImmutableSet;
28
29
30
31
32
33 public class CreateDriveRequest extends Drive {
34 public static class Builder extends Drive.Builder {
35
36 private Set<String> avoid = ImmutableSet.of();
37
38 @Nullable
39 private String encryptionCipher;
40
41 public Builder avoid(Iterable<String> avoid) {
42 this.avoid = ImmutableSet.copyOf(checkNotNull(avoid, "avoid"));
43 return this;
44 }
45
46
47
48
49 @Override
50 public Builder claimType(ClaimType claimType) {
51 return Builder.class.cast(super.claimType(claimType));
52 }
53
54 public Builder encryptionCipher(String encryptionCipher) {
55 this.encryptionCipher = encryptionCipher;
56 return this;
57 }
58
59
60
61
62 @Override
63 public Builder name(String name) {
64 return Builder.class.cast(super.name(name));
65 }
66
67
68
69
70 @Override
71 public Builder readers(Iterable<String> readers) {
72 return Builder.class.cast(super.readers(readers));
73 }
74
75
76
77
78 @Override
79 public Builder size(long size) {
80 return Builder.class.cast(super.size(size));
81 }
82
83
84
85
86 @Override
87 public Builder use(Iterable<String> use) {
88 return Builder.class.cast(super.use(use));
89 }
90
91 public CreateDriveRequest build() {
92 return new CreateDriveRequest(name, size, claimType, readers, use, encryptionCipher, avoid);
93 }
94 }
95
96 private final Set<String> avoid;
97 @Nullable
98 private final String encryptionCipher;
99
100 public CreateDriveRequest(String name, long size, @Nullable ClaimType claimType, Iterable<String> readers,
101 Iterable<String> use, @Nullable String encryptionCipher, Iterable<String> avoid) {
102 super(null, name, size, claimType, readers, use);
103 this.encryptionCipher = encryptionCipher;
104 this.avoid = ImmutableSet.copyOf(checkNotNull(avoid, "avoid"));
105 }
106
107
108
109
110
111
112 public Set<String> getAvoid() {
113 return avoid;
114 }
115
116
117
118
119
120 @Nullable
121 public String getEncryptionCipher() {
122 return encryptionCipher;
123 }
124
125 @Override
126 public int hashCode() {
127 final int prime = 31;
128 int result = super.hashCode();
129 result = prime * result + ((avoid == null) ? 0 : avoid.hashCode());
130 result = prime * result + ((encryptionCipher == null) ? 0 : encryptionCipher.hashCode());
131 return result;
132 }
133
134 @Override
135 public boolean equals(Object obj) {
136 if (this == obj)
137 return true;
138 if (!super.equals(obj))
139 return false;
140 if (getClass() != obj.getClass())
141 return false;
142 CreateDriveRequest other = (CreateDriveRequest) obj;
143 if (avoid == null) {
144 if (other.avoid != null)
145 return false;
146 } else if (!avoid.equals(other.avoid))
147 return false;
148 if (encryptionCipher == null) {
149 if (other.encryptionCipher != null)
150 return false;
151 } else if (!encryptionCipher.equals(other.encryptionCipher))
152 return false;
153 return true;
154 }
155
156 @Override
157 public String toString() {
158 return "[name=" + name + ", size=" + size + ", claimType=" + claimType + ", readers=" + readers + ", use=" + use
159 + ", avoid=" + avoid + ", encryptionCipher=" + encryptionCipher + "]";
160 }
161 }