Skip to content

Commit f8e0791

Browse files
committed
---
yaml --- r: 3559 b: refs/heads/pubsub-alpha c: 5be58b3 h: refs/heads/master i: 3557: be02026 3555: fc8f001 3551: 29af0f8
1 parent 892cfb6 commit f8e0791

5 files changed

Lines changed: 210 additions & 74 deletions

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 36a62ef856d199f8efd09501b5ba65c422c01f23
33
refs/heads/travis: e21ee7b88a5edc3f3d8c71f90c3fc32abf7e8dd6
44
refs/heads/gh-pages: 7406918e071dd2c5677a638ae2a06e7592b6542c
5-
refs/heads/pubsub-alpha: b12854832fd42476a4f15fe0150f620bc68ac054
5+
refs/heads/pubsub-alpha: 5be58b3e91cade1d349014122484a29e254ba8f3
66
refs/heads/update-datastore: 47aae517c2cb33f1dccd909adaced73ec9d0f4df
77
refs/tags/0.0.9: 22f1839238f66c39e67ed4dfdcd273b1ae2e8444
88
refs/tags/v0.0.10: 207ebd2a3472fddee69fe1298eb90429e3306efd

branches/pubsub-alpha/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ public static ChangeRequestListOption sortOrder(SortingOrder order) {
439439
* @see <a href="https://cloud.google.com/dns/api/v1/managedZones/get">Cloud DNS Managed Zones:
440440
* get</a>
441441
*/
442-
ZoneInfo getZone(String zoneName, ZoneOption... options);
442+
Zone getZone(String zoneName, ZoneOption... options);
443443

444444
/**
445445
* Lists the zones inside the project.

branches/pubsub-alpha/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Zone.java

Lines changed: 98 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020

2121
import com.google.gcloud.Page;
2222

23-
import java.io.Serializable;
23+
import java.util.List;
24+
import java.util.Objects;
2425

2526
/**
2627
* A Google Cloud DNS Zone object.
@@ -33,20 +34,87 @@
3334
* @see <a href="https://cloud.google.com/dns/zones/">Google Cloud DNS managed zone
3435
* documentation</a>
3536
*/
36-
public class Zone implements Serializable {
37+
public class Zone extends ZoneInfo {
3738

38-
// TODO(mderka) Zone and zoneInfo to be merged. Opened issue #605.
39+
private static final long serialVersionUID = 564454483894599281L;
40+
private transient Dns dns;
3941

40-
private static final long serialVersionUID = 6847890192129375500L;
41-
private final ZoneInfo zoneInfo;
42-
private final Dns dns;
42+
/**
43+
* Builder for {@code Zone}.
44+
*/
45+
public static class Builder extends ZoneInfo.Builder {
46+
private final Dns dns;
47+
private final ZoneInfo.BuilderImpl infoBuilder;
48+
49+
private Builder(Zone zone) {
50+
this.dns = zone.dns;
51+
this.infoBuilder = new ZoneInfo.BuilderImpl(zone);
52+
}
53+
54+
@Override
55+
public Builder name(String name) {
56+
infoBuilder.name(name);
57+
return this;
58+
}
59+
60+
@Override
61+
Builder id(String id) {
62+
infoBuilder.id(id);
63+
return this;
64+
}
65+
66+
@Override
67+
Builder creationTimeMillis(long creationTimeMillis) {
68+
infoBuilder.creationTimeMillis(creationTimeMillis);
69+
return this;
70+
}
71+
72+
@Override
73+
public Builder dnsName(String dnsName) {
74+
infoBuilder.dnsName(dnsName);
75+
return this;
76+
}
77+
78+
@Override
79+
public Builder description(String description) {
80+
infoBuilder.description(description);
81+
return this;
82+
}
83+
84+
@Override
85+
public Builder nameServerSet(String nameServerSet) {
86+
infoBuilder.nameServerSet(nameServerSet);
87+
return this;
88+
}
89+
90+
@Override
91+
Builder nameServers(List<String> nameServers) {
92+
infoBuilder.nameServers(nameServers); // infoBuilder makes a copy
93+
return this;
94+
}
95+
96+
@Override
97+
public Zone build() {
98+
return new Zone(dns, infoBuilder);
99+
}
100+
}
101+
102+
Zone(Dns dns, ZoneInfo.BuilderImpl infoBuilder) {
103+
super(infoBuilder);
104+
this.dns = dns;
105+
}
106+
107+
@Override
108+
public Builder toBuilder() {
109+
return new Builder(this);
110+
}
43111

44112
/**
45113
* Constructs a {@code Zone} object that contains the given {@code zoneInfo}.
46114
*/
47115
public Zone(Dns dns, ZoneInfo zoneInfo) {
48-
this.zoneInfo = checkNotNull(zoneInfo);
49-
this.dns = checkNotNull(dns);
116+
super(new BuilderImpl(zoneInfo));
117+
this.dns = dns;
50118
}
51119

52120
/**
@@ -61,8 +129,7 @@ public Zone(Dns dns, ZoneInfo zoneInfo) {
61129
public static Zone get(Dns dnsService, String zoneName, Dns.ZoneOption... options) {
62130
checkNotNull(zoneName);
63131
checkNotNull(dnsService);
64-
ZoneInfo zoneInfo = dnsService.getZone(zoneName, options);
65-
return zoneInfo == null ? null : new Zone(dnsService, zoneInfo);
132+
return dnsService.getZone(zoneName, options);
66133
}
67134

68135
/**
@@ -73,7 +140,7 @@ public static Zone get(Dns dnsService, String zoneName, Dns.ZoneOption... option
73140
* @throws DnsException upon failure
74141
*/
75142
public Zone reload(Dns.ZoneOption... options) {
76-
return Zone.get(dns, zoneInfo.name(), options);
143+
return dns.getZone(name(), options);
77144
}
78145

79146
/**
@@ -83,7 +150,7 @@ public Zone reload(Dns.ZoneOption... options) {
83150
* @throws DnsException upon failure
84151
*/
85152
public boolean delete() {
86-
return dns.delete(zoneInfo.name());
153+
return dns.delete(name());
87154
}
88155

89156
/**
@@ -94,7 +161,7 @@ public boolean delete() {
94161
* @throws DnsException upon failure or if the zone is not found
95162
*/
96163
public Page<DnsRecord> listDnsRecords(Dns.DnsRecordListOption... options) {
97-
return dns.listDnsRecords(zoneInfo.name(), options);
164+
return dns.listDnsRecords(name(), options);
98165
}
99166

100167
/**
@@ -108,7 +175,7 @@ public Page<DnsRecord> listDnsRecords(Dns.DnsRecordListOption... options) {
108175
public ChangeRequest applyChangeRequest(ChangeRequest changeRequest,
109176
Dns.ChangeRequestOption... options) {
110177
checkNotNull(changeRequest);
111-
return dns.applyChangeRequest(zoneInfo.name(), changeRequest, options);
178+
return dns.applyChangeRequest(name(), changeRequest, options);
112179
}
113180

114181
/**
@@ -124,7 +191,7 @@ public ChangeRequest applyChangeRequest(ChangeRequest changeRequest,
124191
public ChangeRequest getChangeRequest(String changeRequestId,
125192
Dns.ChangeRequestOption... options) {
126193
checkNotNull(changeRequestId);
127-
return dns.getChangeRequest(zoneInfo.name(), changeRequestId, options);
194+
return dns.getChangeRequest(name(), changeRequestId, options);
128195
}
129196

130197
/**
@@ -136,14 +203,7 @@ public ChangeRequest getChangeRequest(String changeRequestId,
136203
* @throws DnsException upon failure or if the zone is not found
137204
*/
138205
public Page<ChangeRequest> listChangeRequests(Dns.ChangeRequestListOption... options) {
139-
return dns.listChangeRequests(zoneInfo.name(), options);
140-
}
141-
142-
/**
143-
* Returns the {@link ZoneInfo} object containing information about this zone.
144-
*/
145-
public ZoneInfo info() {
146-
return zoneInfo;
206+
return dns.listChangeRequests(name(), options);
147207
}
148208

149209
/**
@@ -152,4 +212,19 @@ public ZoneInfo info() {
152212
public Dns dns() {
153213
return this.dns;
154214
}
215+
216+
@Override
217+
public boolean equals(Object obj) {
218+
return obj instanceof Zone && Objects.equals(toPb(), ((Zone) obj).toPb());
219+
}
220+
221+
@Override
222+
public int hashCode() {
223+
return super.hashCode();
224+
}
225+
226+
static Zone fromPb(Dns dns, com.google.api.services.dns.model.ManagedZone zone) {
227+
ZoneInfo info = ZoneInfo.fromPb(zone);
228+
return new Zone(dns, info);
229+
}
155230
}

0 commit comments

Comments
 (0)