diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsRecord.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsRecord.java index a3a673b99cc6..99ca20386419 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsRecord.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsRecord.java @@ -22,6 +22,7 @@ import com.google.common.base.MoreObjects; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; +import com.google.common.primitives.Ints; import java.io.Serializable; import java.util.LinkedList; @@ -187,13 +188,9 @@ public Builder ttl(int duration, TimeUnit unit) { checkArgument(duration >= 0, "Duration cannot be negative. The supplied value was %s.", duration); checkNotNull(unit); - // convert to seconds and check that we are not overflowing int - // we cannot do that because pb does not support it + // we cannot have long because pb does not support it long converted = unit.toSeconds(duration); - checkArgument(converted <= Integer.MAX_VALUE, - "The duration converted to seconds is out of range of int. The value converts to %s sec.", - converted); - ttl = (int) converted; + ttl = Ints.checkedCast(converted); return this; } diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ProjectInfo.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ProjectInfo.java index b7933956ed88..4db0497946b1 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ProjectInfo.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ProjectInfo.java @@ -50,7 +50,7 @@ public static class Quota { private final int resourceRecordsPerRrset; private final int rrsetAdditionsPerChange; private final int rrsetDeletionsPerChange; - private final int rrsetsPerManagedZone; + private final int rrsetsPerZone; private final int totalRrdataSizePerChange; /** @@ -64,13 +64,13 @@ public static class Quota { int resourceRecordsPerRrset, int rrsetAdditionsPerChange, int rrsetDeletionsPerChange, - int rrsetsPerManagedZone, + int rrsetsPerZone, int totalRrdataSizePerChange) { this.zones = zones; this.resourceRecordsPerRrset = resourceRecordsPerRrset; this.rrsetAdditionsPerChange = rrsetAdditionsPerChange; this.rrsetDeletionsPerChange = rrsetDeletionsPerChange; - this.rrsetsPerManagedZone = rrsetsPerManagedZone; + this.rrsetsPerZone = rrsetsPerZone; this.totalRrdataSizePerChange = totalRrdataSizePerChange; } @@ -107,8 +107,8 @@ public int rrsetDeletionsPerChange() { * Returns the maximum allowed number of {@link DnsRecord}s per {@link ZoneInfo} in the * project. */ - public int rrsetsPerManagedZone() { - return rrsetsPerManagedZone; + public int rrsetsPerZone() { + return rrsetsPerZone; } /** @@ -126,7 +126,7 @@ public boolean equals(Object other) { @Override public int hashCode() { return Objects.hash(zones, resourceRecordsPerRrset, rrsetAdditionsPerChange, - rrsetDeletionsPerChange, rrsetsPerManagedZone, totalRrdataSizePerChange); + rrsetDeletionsPerChange, rrsetsPerZone, totalRrdataSizePerChange); } com.google.api.services.dns.model.Quota toPb() { @@ -135,7 +135,7 @@ com.google.api.services.dns.model.Quota toPb() { pb.setResourceRecordsPerRrset(resourceRecordsPerRrset); pb.setRrsetAdditionsPerChange(rrsetAdditionsPerChange); pb.setRrsetDeletionsPerChange(rrsetDeletionsPerChange); - pb.setRrsetsPerManagedZone(rrsetsPerManagedZone); + pb.setRrsetsPerManagedZone(rrsetsPerZone); pb.setTotalRrdataSizePerChange(totalRrdataSizePerChange); return pb; } @@ -158,7 +158,7 @@ public String toString() { .add("resourceRecordsPerRrset", resourceRecordsPerRrset) .add("rrsetAdditionsPerChange", rrsetAdditionsPerChange) .add("rrsetDeletionsPerChange", rrsetDeletionsPerChange) - .add("rrsetsPerManagedZone", rrsetsPerManagedZone) + .add("rrsetsPerZone", rrsetsPerZone) .add("totalRrdataSizePerChange", totalRrdataSizePerChange) .toString(); } diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ProjectInfoTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ProjectInfoTest.java index 2af8b5ad3995..5c2f2692c2c1 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ProjectInfoTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ProjectInfoTest.java @@ -57,7 +57,7 @@ public void testQuotaConstructor() { assertEquals(2, QUOTA.resourceRecordsPerRrset()); assertEquals(3, QUOTA.rrsetAdditionsPerChange()); assertEquals(4, QUOTA.rrsetDeletionsPerChange()); - assertEquals(5, QUOTA.rrsetsPerManagedZone()); + assertEquals(5, QUOTA.rrsetsPerZone()); assertEquals(6, QUOTA.totalRrdataSizePerChange()); }