1616
1717package com .google .gcloud .dns ;
1818
19- import static com .google .common .base .Preconditions .checkArgument ;
2019import static com .google .common .base .Preconditions .checkNotNull ;
2120
2221import com .google .common .base .MoreObjects ;
2322import com .google .common .collect .ImmutableList ;
23+ import com .google .common .collect .Lists ;
2424
2525import org .joda .time .DateTime ;
2626import org .joda .time .format .ISODateTimeFormat ;
3232import java .util .Objects ;
3333
3434/**
35- * This class is a container for the managed zone metainformation. Managed zone is a resource that
36- * represents a DNS zone hosted by the Cloud DNS service. See <a href="https://cloud.google.com/dns/api/v1/managedZones">Google
37- * Cloud DNS documentation</a> for more information.
35+ * A {@code ManagedZone} represents a DNS zone hosted by the Google Cloud DNS service. A zone is a
36+ * subtree of the DNS namespace under one administrative responsibility. See <a
37+ * href="https://cloud.google.com/dns/api/v1/managedZones">Google Cloud DNS documentation</a> for
38+ * more information.
3839 */
3940public class ManagedZoneInfo implements Serializable {
4041
4142 private static final long serialVersionUID = 201601191647L ;
4243 private final String name ;
43- private final Long id ;
44+ private final BigInteger id ;
4445 private final Long creationTimeMillis ;
4546 private final String dnsName ;
4647 private final String description ;
@@ -52,25 +53,29 @@ public class ManagedZoneInfo implements Serializable {
5253 */
5354 public static class Builder {
5455 private String name ;
55- private Long id ;
56+ private BigInteger id ;
5657 private Long creationTimeMillis ;
5758 private String dnsName ;
5859 private String description ;
5960 private String nameServerSet ;
6061 private List <String > nameServers = new LinkedList <>();
6162
63+ /**
64+ * Returns an empty builder for {@code ManagedZoneInfo}. We use it internally in {@code
65+ * toPb()}.
66+ */
6267 private Builder () {
6368 }
6469
65- private Builder (Long id ) {
70+ private Builder (BigInteger id ) {
6671 this .id = checkNotNull (id );
6772 }
6873
6974 private Builder (String name ) {
7075 this .name = checkNotNull (name );
7176 }
7277
73- private Builder (String name , Long id ) {
78+ private Builder (String name , BigInteger id ) {
7479 this .name = checkNotNull (name );
7580 this .id = checkNotNull (id );
7681 }
@@ -99,7 +104,7 @@ public Builder name(String name) {
99104 /**
100105 * Sets an id for the managed zone which is assigned to the managed zone by the server.
101106 */
102- public Builder id (long id ) {
107+ Builder id (BigInteger id ) {
103108 this .id = id ;
104109 return this ;
105110 }
@@ -108,7 +113,6 @@ public Builder id(long id) {
108113 * Sets the time when this managed zone was created.
109114 */
110115 Builder creationTimeMillis (long creationTimeMillis ) {
111- checkArgument (creationTimeMillis >= 0 , "The timestamp cannot be negative." );
112116 this .creationTimeMillis = creationTimeMillis ;
113117 return this ;
114118 }
@@ -123,8 +127,7 @@ public Builder dnsName(String dnsName) {
123127
124128 /**
125129 * Sets a mandatory description for this managed zone. The value is a string of at most 1024
126- * characters (this limit is posed by Google Cloud DNS; gcloud-java does not enforce the limit)
127- * which has no effect on the managed zone's function.
130+ * characters which has no effect on the managed zone's function.
128131 */
129132 public Builder description (String description ) {
130133 this .description = checkNotNull (description );
@@ -133,7 +136,8 @@ public Builder description(String description) {
133136
134137 /**
135138 * Optionally specifies the NameServerSet for this managed zone. A NameServerSet is a set of DNS
136- * name servers that all host the same ManagedZones.
139+ * name servers that all host the same ManagedZones. Most users will not need to specify this
140+ * value.
137141 */
138142 public Builder nameServerSet (String nameServerSet ) {
139143 // todo(mderka) add more to the doc when questions are answered by the service owner
@@ -146,20 +150,13 @@ public Builder nameServerSet(String nameServerSet) {
146150 * provided by Google Cloud DNS and is read only.
147151 */
148152 Builder nameServers (List <String > nameServers ) {
149- this .nameServers .addAll (checkNotNull (nameServers ));
153+ checkNotNull (nameServers );
154+ this .nameServers = Lists .newLinkedList (nameServers );
150155 return this ;
151156 }
152157
153158 /**
154- * Removes all the nameservers from the list.
155- */
156- Builder clearNameServers () {
157- this .nameServers .clear ();
158- return this ;
159- }
160-
161- /**
162- * Builds the instance of ManagedZoneInfo based on the information set here.
159+ * Builds the instance of {@code ManagedZoneInfo} based on the information set by this builder.
163160 */
164161 public ManagedZoneInfo build () {
165162 return new ManagedZoneInfo (this );
@@ -186,24 +183,17 @@ public static Builder builder(String name) {
186183 /**
187184 * Returns a builder for {@code ManagedZoneInfo} with an assigned {@code id}.
188185 */
189- public static Builder builder (Long id ) {
186+ public static Builder builder (BigInteger id ) {
190187 return new Builder (id );
191188 }
192189
193190 /**
194191 * Returns a builder for {@code ManagedZoneInfo} with an assigned {@code name} and {@code id}.
195192 */
196- public static Builder builder (String name , Long id ) {
193+ public static Builder builder (String name , BigInteger id ) {
197194 return new Builder (name , id );
198195 }
199196
200- /**
201- * Returns an empty builder for {@code ManagedZoneInfo}. We use it internally in {@code toPb()}.
202- */
203- private static Builder builder () {
204- return new Builder ();
205- }
206-
207197 /**
208198 * Returns the user-defined name of the managed zone.
209199 */
@@ -214,7 +204,7 @@ public String name() {
214204 /**
215205 * Returns the read-only managed zone id assigned by the server.
216206 */
217- public Long id () {
207+ public BigInteger id () {
218208 return id ;
219209 }
220210
@@ -233,8 +223,7 @@ public String dnsName() {
233223 }
234224
235225 /**
236- * Returns the description of this managed zone. This is at most 1024 long mandatory string
237- * provided by the user.
226+ * Returns the description of this managed zone.
238227 */
239228 public String description () {
240229 return description ;
@@ -270,7 +259,7 @@ com.google.api.services.dns.model.ManagedZone toPb() {
270259 pb .setDescription (this .description ());
271260 pb .setDnsName (this .dnsName ());
272261 if (this .id () != null ) {
273- pb .setId (BigInteger . valueOf ( this .id () ));
262+ pb .setId (this .id ());
274263 }
275264 pb .setName (this .name ());
276265 pb .setNameServers (this .nameServers ());
@@ -284,15 +273,15 @@ com.google.api.services.dns.model.ManagedZone toPb() {
284273 }
285274
286275 static ManagedZoneInfo fromPb (com .google .api .services .dns .model .ManagedZone pb ) {
287- Builder b = builder ();
276+ Builder b = new Builder ();
288277 if (pb .getDescription () != null ) {
289278 b .description (pb .getDescription ());
290279 }
291280 if (pb .getDnsName () != null ) {
292281 b .dnsName (pb .getDnsName ());
293282 }
294283 if (pb .getId () != null ) {
295- b .id (pb .getId (). longValue () );
284+ b .id (pb .getId ());
296285 }
297286 if (pb .getName () != null ) {
298287 b .name (pb .getName ());
0 commit comments