Skip to content

Commit

Permalink
Implemented comments by @aozarov.
Browse files Browse the repository at this point in the history
  • Loading branch information
mderka committed Jan 28, 2016
1 parent c364ff3 commit c57865f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -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;
}

Expand Down Expand Up @@ -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;
}

/**
Expand All @@ -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() {
Expand All @@ -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;
}
Expand All @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

Expand Down

0 comments on commit c57865f

Please sign in to comment.