Skip to content

Commit 8ed547b

Browse files
committed
Implements comment from @aozarov and @ajkannan into ProjectInfo.
1 parent feb237c commit 8ed547b

File tree

2 files changed

+48
-47
lines changed

2 files changed

+48
-47
lines changed

gcloud-java-dns/src/main/java/com/google/gcloud/dns/ProjectInfo.java

Lines changed: 42 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@
2525
import java.util.Objects;
2626

2727
/**
28-
* The class that encapsulates information about a project in Google Cloud DNS. A project is a top
29-
* level container for resources including {@code ManagedZone}s. Projects can be created only in the
30-
* APIs console.
28+
* The class provides the Google Cloud DNS information associated with this project. A project is a
29+
* top level container for resources including {@code ManagedZone}s. Projects can be created only in
30+
* the APIs console.
3131
*
3232
* @see <a href="https://cloud.google.com/dns/api/v1/projects">Google Cloud DNS documentation</a>
3333
*/
@@ -41,16 +41,17 @@ public class ProjectInfo implements Serializable {
4141
/**
4242
* This class represents quotas assigned to the {@code ProjectInfo}.
4343
*
44-
* @see <a href="https://cloud.google.com/dns/api/v1/projects">Google Cloud DNS documentation</a>
44+
* @see <a href="https://cloud.google.com/dns/api/v1/projects#quota">Google Cloud DNS
45+
* documentation</a>
4546
*/
4647
public static class Quota {
4748

48-
private Integer zones;
49-
private Integer resourceRecordsPerRrset;
50-
private Integer rrsetAdditionsPerChange;
51-
private Integer rrsetDeletionsPerChange;
52-
private Integer rrsetsPerManagedZone;
53-
private Integer totalRrdataSizePerChange;
49+
private final int zones;
50+
private final int resourceRecordsPerRrset;
51+
private final int rrsetAdditionsPerChange;
52+
private final int rrsetDeletionsPerChange;
53+
private final int rrsetsPerManagedZone;
54+
private final int totalRrdataSizePerChange;
5455

5556
/**
5657
* Creates an instance of {@code Quota}.
@@ -59,61 +60,61 @@ public static class Quota {
5960
* allow for specifying options, quota is an "all-or-nothing object" and we do not need a
6061
* builder.
6162
*/
62-
Quota(Integer zones,
63-
Integer resourceRecordsPerRrset,
64-
Integer rrsetAdditionsPerChange,
65-
Integer rrsetDeletionsPerChange,
66-
Integer rrsetsPerManagedZone,
67-
Integer totalRrdataSizePerChange) {
68-
this.zones = checkNotNull(zones);
69-
this.resourceRecordsPerRrset = checkNotNull(resourceRecordsPerRrset);
70-
this.rrsetAdditionsPerChange = checkNotNull(rrsetAdditionsPerChange);
71-
this.rrsetDeletionsPerChange = checkNotNull(rrsetDeletionsPerChange);
72-
this.rrsetsPerManagedZone = checkNotNull(rrsetsPerManagedZone);
73-
this.totalRrdataSizePerChange = checkNotNull(totalRrdataSizePerChange);
63+
Quota(int zones,
64+
int resourceRecordsPerRrset,
65+
int rrsetAdditionsPerChange,
66+
int rrsetDeletionsPerChange,
67+
int rrsetsPerManagedZone,
68+
int totalRrdataSizePerChange) {
69+
this.zones = zones;
70+
this.resourceRecordsPerRrset = resourceRecordsPerRrset;
71+
this.rrsetAdditionsPerChange = rrsetAdditionsPerChange;
72+
this.rrsetDeletionsPerChange = rrsetDeletionsPerChange;
73+
this.rrsetsPerManagedZone = rrsetsPerManagedZone;
74+
this.totalRrdataSizePerChange = totalRrdataSizePerChange;
7475
}
7576

7677
/**
7778
* Returns the maximum allowed number of managed zones in the project.
7879
*/
79-
public Integer zones() {
80+
public int zones() {
8081
return zones;
8182
}
8283

8384
/**
8485
* Returns the maximum allowed number of records per {@link DnsRecord}.
8586
*/
86-
public Integer resourceRecordsPerRrset() {
87+
public int resourceRecordsPerRrset() {
8788
return resourceRecordsPerRrset;
8889
}
8990

9091
/**
9192
* Returns the maximum allowed number of {@link DnsRecord}s to add per {@code ChangesRequest}.
9293
*/
93-
public Integer rrsetAdditionsPerChange() {
94+
public int rrsetAdditionsPerChange() {
9495
return rrsetAdditionsPerChange;
9596
}
9697

9798
/**
9899
* Returns the maximum allowed number of {@link DnsRecord}s to delete per {@code
99100
* ChangesRequest}.
100101
*/
101-
public Integer rrsetDeletionsPerChange() {
102+
public int rrsetDeletionsPerChange() {
102103
return rrsetDeletionsPerChange;
103104
}
104105

105106
/**
106107
* Returns the maximum allowed number of {@link DnsRecord}s per {@code ManagedZone} in the
107108
* project.
108109
*/
109-
public Integer rrsetsPerManagedZone() {
110+
public int rrsetsPerManagedZone() {
110111
return rrsetsPerManagedZone;
111112
}
112113

113114
/**
114115
* Returns the maximum allowed size for total records in one ChangesRequest in bytes.
115116
*/
116-
public Integer totalRrdataSizePerChange() {
117+
public int totalRrdataSizePerChange() {
117118
return totalRrdataSizePerChange;
118119
}
119120

@@ -220,32 +221,32 @@ static Builder builder() {
220221
}
221222

222223
/**
223-
* Returns the user-assigned unique identifier for the project.
224+
* Returns the {@code Quota} object which contains quotas assigned to this project.
224225
*/
225-
public String id() {
226-
return id;
226+
public Quota quota() {
227+
return quota;
227228
}
228229

229230
/**
230-
* Returns the unique numeric identifier for the project.
231+
* Returns project number. For internal use only.
231232
*/
232-
public BigInteger number() {
233+
BigInteger number() {
233234
return number;
234235
}
235236

236237
/**
237-
* Returns the {@code Quota} object which contains quotas assigned to this project.
238+
* Returns project id. For internal use only.
238239
*/
239-
public Quota quota() {
240-
return quota;
240+
String id() {
241+
return id;
241242
}
242243

243244
com.google.api.services.dns.model.Project toPb() {
244245
com.google.api.services.dns.model.Project pb = new com.google.api.services.dns.model.Project();
245-
pb.setId(id());
246-
pb.setNumber(number());
247-
if (this.quota() != null) {
248-
pb.setQuota(quota().toPb());
246+
pb.setId(id);
247+
pb.setNumber(number);
248+
if (this.quota != null) {
249+
pb.setQuota(quota.toPb());
249250
}
250251
return pb;
251252
}
@@ -266,7 +267,7 @@ static ProjectInfo fromPb(com.google.api.services.dns.model.Project pb) {
266267

267268
@Override
268269
public boolean equals(Object other) {
269-
return (other instanceof ProjectInfo) && this.toPb().equals(((ProjectInfo) other).toPb());
270+
return (other instanceof ProjectInfo) && toPb().equals(((ProjectInfo) other).toPb());
270271
}
271272

272273
@Override

gcloud-java-dns/src/test/java/com/google/gcloud/dns/ProjectInfoTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ public void testBuilder() {
5353

5454
@Test
5555
public void testQuotaConstructor() {
56-
assertEquals(Integer.valueOf(1), QUOTA.zones());
57-
assertEquals(Integer.valueOf(2), QUOTA.resourceRecordsPerRrset());
58-
assertEquals(Integer.valueOf(3), QUOTA.rrsetAdditionsPerChange());
59-
assertEquals(Integer.valueOf(4), QUOTA.rrsetDeletionsPerChange());
60-
assertEquals(Integer.valueOf(5), QUOTA.rrsetsPerManagedZone());
61-
assertEquals(Integer.valueOf(6), QUOTA.totalRrdataSizePerChange());
56+
assertEquals(1, QUOTA.zones());
57+
assertEquals(2, QUOTA.resourceRecordsPerRrset());
58+
assertEquals(3, QUOTA.rrsetAdditionsPerChange());
59+
assertEquals(4, QUOTA.rrsetDeletionsPerChange());
60+
assertEquals(5, QUOTA.rrsetsPerManagedZone());
61+
assertEquals(6, QUOTA.totalRrdataSizePerChange());
6262
}
6363

6464
@Test

0 commit comments

Comments
 (0)