We have the following precondition-style utilities inside of google:
Durations.checkNotNegative(duration)
Durations.checkPositive(duration)
They throw IllegalArgumentException if the duration is negative or not positive (respectively). Negative durations often are a bug, so it's nice to validate Duration parameters like RPC timeouts or cache expirations. E.g.,
public final class Frobber {
private final Duration timeout;
public Frobber(Duration timeout) {
this.timeout = checkPositive(timeout);
}
}
Any chance we could find a home for these in threeten-extra?
We have the following precondition-style utilities inside of google:
Durations.checkNotNegative(duration)Durations.checkPositive(duration)They throw
IllegalArgumentExceptionif the duration is negative or not positive (respectively). Negative durations often are a bug, so it's nice to validateDurationparameters like RPC timeouts or cache expirations. E.g.,Any chance we could find a home for these in threeten-extra?