Skip to content

Commit

Permalink
Added computed end to Buckets class
Browse files Browse the repository at this point in the history
  • Loading branch information
tsegismont committed Mar 19, 2015
1 parent 8b4ead7 commit ecd314e
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public final class Buckets {
private final long start;
private final long step;
private final int count;
private final long end;

public Buckets(long start, long step, int count) {
checkArgument(start > 0, "start is not positive");
Expand All @@ -48,6 +49,7 @@ public Buckets(long start, long step, int count) {
this.step = step;
checkArgument(count > 0, "count is not positive");
this.count = count;
end = start + count * step;
}

public long getStart() {
Expand All @@ -62,6 +64,17 @@ public int getCount() {
return count;
}

/**
* Computed end. If this instance was created with {@link #fromCount(long, long, int)} or
* {@link #fromStep(long, long, long)}, then it could be different from the value specified as the {@code end}
* parameter of these factory methods.
*
* @return the computed end (start + count * step)
*/
public long getEnd() {
return end;
}

@Override
public boolean equals(Object o) {
if (this == o) {
Expand Down

0 comments on commit ecd314e

Please sign in to comment.