MCPcopy Create free account
hub / github.com/grpc/grpc-java / durationIsValid

Method durationIsValid

core/src/main/java/io/grpc/internal/JsonUtil.java:400–413  ·  view source on GitHub ↗

Returns true if the given number of seconds and nanos is a valid Duration. The seconds value must be in the range [-315,576,000,000, +315,576,000,000]. The nanos value must be in the range [-999,999,999, +999,999,999]. Note: Durations less than one second are repre

(long seconds, int nanos)

Source from the content-addressed store, hash-verified

398 * <p>Copy of {@link com.google.protobuf.util.Duration#isValid}.</p>
399 */
400 private static boolean durationIsValid(long seconds, int nanos) {
401 if (seconds < DURATION_SECONDS_MIN || seconds > DURATION_SECONDS_MAX) {
402 return false;
403 }
404 if (nanos < -999999999L || nanos >= NANOS_PER_SECOND) {
405 return false;
406 }
407 if (seconds < 0 || nanos < 0) {
408 if (seconds > 0 || nanos > 0) {
409 return false;
410 }
411 }
412 return true;
413 }
414
415 /**
416 * Returns the sum of {@code a} and {@code b} unless it would overflow or underflow in which case

Callers 1

normalizedDurationMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected