Codota Logo
Duration.compareTo
Code IndexAdd Codota to your IDE (free)

How to use
compareTo
method
in
org.threeten.bp.Duration

Best Java code snippets using org.threeten.bp.Duration.compareTo (Showing top 19 results out of 315)

  • Common ways to obtain Duration
private void myMethod () {
Duration d =
  • Codota IconDuration.ofSeconds(long1)
  • Codota IconDuration.ofMillis(long1)
  • Smart code suggestions by Codota
}
origin: googleapis/google-cloud-java

/** Configures the Publisher's retry parameters. */
public Builder setRetrySettings(RetrySettings retrySettings) {
 Preconditions.checkArgument(
   retrySettings.getTotalTimeout().compareTo(MIN_TOTAL_TIMEOUT) >= 0);
 Preconditions.checkArgument(
   retrySettings.getInitialRpcTimeout().compareTo(MIN_RPC_TIMEOUT) >= 0);
 this.retrySettings = retrySettings;
 return this;
}
origin: googleapis/google-cloud-java

/**
 * Set acknowledgement expiration padding.
 *
 * <p>This is the time accounted before a message expiration is to happen, so the {@link
 * Subscriber} is able to send an ack extension beforehand.
 *
 * <p>This padding duration is configurable so you can account for network latency. A reasonable
 * number must be provided so messages don't expire because of network latency between when the
 * ack extension is required and when it reaches the Pub/Sub service.
 *
 * @param ackExpirationPadding must be greater or equal to {@link #MIN_ACK_EXPIRATION_PADDING}
 */
@InternalApi
Builder setAckExpirationPadding(Duration ackExpirationPadding) {
 Preconditions.checkArgument(ackExpirationPadding.compareTo(MIN_ACK_EXPIRATION_PADDING) >= 0);
 this.ackExpirationPadding = ackExpirationPadding;
 return this;
}
origin: googleapis/google-cloud-java

  builder.ackExpirationPadding.compareTo(Duration.ZERO) > 0, "padding must be positive");
Preconditions.checkArgument(
  builder.ackExpirationPadding.compareTo(Duration.ofSeconds(MIN_ACK_DEADLINE_SECONDS)) < 0,
  "padding must be less than %s seconds",
  MIN_ACK_DEADLINE_SECONDS);
origin: com.google.api/gax

 /**
  * This method simply calls {@link Thread#sleep(long)}.
  *
  * @param delay time to sleep
  * @throws InterruptedException if any thread has interrupted the current thread
  */
 protected void sleep(Duration delay) throws InterruptedException {
  if (Duration.ZERO.compareTo(delay) < 0) {
   Thread.sleep(delay.toMillis());
  }
 }
}
origin: googleapis/gax-java

 /**
  * This method simply calls {@link Thread#sleep(long)}.
  *
  * @param delay time to sleep
  * @throws InterruptedException if any thread has interrupted the current thread
  */
 protected void sleep(Duration delay) throws InterruptedException {
  if (Duration.ZERO.compareTo(delay) < 0) {
   Thread.sleep(delay.toMillis());
  }
 }
}
origin: com.google.api/gax-grpc

@Override
public GrpcCallContext withStreamIdleTimeout(@Nullable Duration streamIdleTimeout) {
 if (streamIdleTimeout != null) {
  Preconditions.checkArgument(
    streamIdleTimeout.compareTo(Duration.ZERO) >= 0, "Invalid timeout: < 0 s");
 }
 return new GrpcCallContext(
   channel,
   callOptions,
   timeout,
   streamWaitTimeout,
   streamIdleTimeout,
   channelAffinity,
   extraHeaders);
}
origin: com.google.api/gax-grpc

@Override
public GrpcCallContext withStreamWaitTimeout(@Nullable Duration streamWaitTimeout) {
 if (streamWaitTimeout != null) {
  Preconditions.checkArgument(
    streamWaitTimeout.compareTo(Duration.ZERO) >= 0, "Invalid timeout: < 0 s");
 }
 return new GrpcCallContext(
   channel,
   callOptions,
   timeout,
   streamWaitTimeout,
   streamIdleTimeout,
   channelAffinity,
   extraHeaders);
}
origin: googleapis/gax-java

@Override
public GrpcCallContext withStreamWaitTimeout(@Nullable Duration streamWaitTimeout) {
 if (streamWaitTimeout != null) {
  Preconditions.checkArgument(
    streamWaitTimeout.compareTo(Duration.ZERO) >= 0, "Invalid timeout: < 0 s");
 }
 return new GrpcCallContext(
   channel,
   callOptions,
   timeout,
   streamWaitTimeout,
   streamIdleTimeout,
   channelAffinity,
   extraHeaders);
}
origin: googleapis/gax-java

@Override
public GrpcCallContext withStreamIdleTimeout(@Nullable Duration streamIdleTimeout) {
 if (streamIdleTimeout != null) {
  Preconditions.checkArgument(
    streamIdleTimeout.compareTo(Duration.ZERO) >= 0, "Invalid timeout: < 0 s");
 }
 return new GrpcCallContext(
   channel,
   callOptions,
   timeout,
   streamWaitTimeout,
   streamIdleTimeout,
   channelAffinity,
   extraHeaders);
}
origin: com.google.api/gax-grpc

@Override
public GrpcCallContext withTimeout(@Nullable Duration timeout) {
 // Default RetrySettings use 0 for RPC timeout. Treat that as disabled timeouts.
 if (timeout != null && (timeout.isZero() || timeout.isNegative())) {
  timeout = null;
 }
 // Prevent expanding timeouts
 if (timeout != null && this.timeout != null && this.timeout.compareTo(timeout) <= 0) {
  return this;
 }
 return new GrpcCallContext(
   this.channel,
   this.callOptions,
   timeout,
   this.streamWaitTimeout,
   this.streamIdleTimeout,
   this.channelAffinity,
   this.extraHeaders);
}
origin: com.google.api/gax-httpjson

@Override
public HttpJsonCallContext withTimeout(Duration timeout) {
 // Default RetrySettings use 0 for RPC timeout. Treat that as disabled timeouts.
 if (timeout != null && (timeout.isZero() || timeout.isNegative())) {
  timeout = null;
 }
 // Prevent expanding deadlines
 if (timeout != null && this.timeout != null && this.timeout.compareTo(timeout) <= 0) {
  return this;
 }
 return new HttpJsonCallContext(
   this.channel, timeout, this.deadline, this.credentials, this.extraHeaders, this.tracer);
}
origin: googleapis/gax-java

@Override
public GrpcCallContext withTimeout(@Nullable Duration timeout) {
 // Default RetrySettings use 0 for RPC timeout. Treat that as disabled timeouts.
 if (timeout != null && (timeout.isZero() || timeout.isNegative())) {
  timeout = null;
 }
 // Prevent expanding timeouts
 if (timeout != null && this.timeout != null && this.timeout.compareTo(timeout) <= 0) {
  return this;
 }
 return new GrpcCallContext(
   this.channel,
   this.callOptions,
   timeout,
   this.streamWaitTimeout,
   this.streamIdleTimeout,
   this.channelAffinity,
   this.extraHeaders);
}
origin: googleapis/gax-java

@Override
public HttpJsonCallContext withTimeout(Duration timeout) {
 // Default RetrySettings use 0 for RPC timeout. Treat that as disabled timeouts.
 if (timeout != null && (timeout.isZero() || timeout.isNegative())) {
  timeout = null;
 }
 // Prevent expanding deadlines
 if (timeout != null && this.timeout != null && this.timeout.compareTo(timeout) <= 0) {
  return this;
 }
 return new HttpJsonCallContext(
   this.channel, timeout, this.deadline, this.credentials, this.extraHeaders, this.tracer);
}
origin: com.google.api/gax

 /** Build the BatchingSettings object. */
 public BatchingSettings build() {
  BatchingSettings settings = autoBuild();
  Preconditions.checkArgument(
    settings.getElementCountThreshold() == null || settings.getElementCountThreshold() > 0,
    "elementCountThreshold must be either unset or positive");
  Preconditions.checkArgument(
    settings.getRequestByteThreshold() == null || settings.getRequestByteThreshold() > 0,
    "requestByteThreshold must be either unset or positive");
  Preconditions.checkArgument(
    settings.getDelayThreshold() == null
      || settings.getDelayThreshold().compareTo(Duration.ZERO) > 0,
    "delayThreshold must be either unset or positive");
  return settings;
 }
}
origin: googleapis/gax-java

 /** Build the BatchingSettings object. */
 public BatchingSettings build() {
  BatchingSettings settings = autoBuild();
  Preconditions.checkArgument(
    settings.getElementCountThreshold() == null || settings.getElementCountThreshold() > 0,
    "elementCountThreshold must be either unset or positive");
  Preconditions.checkArgument(
    settings.getRequestByteThreshold() == null || settings.getRequestByteThreshold() > 0,
    "requestByteThreshold must be either unset or positive");
  Preconditions.checkArgument(
    settings.getDelayThreshold() == null
      || settings.getDelayThreshold().compareTo(Duration.ZERO) > 0,
    "delayThreshold must be either unset or positive");
  return settings;
 }
}
origin: com.google.api/gax

public RetrySettings build() {
 RetrySettings params = autoBuild();
 if (params.getTotalTimeout().toMillis() < 0) {
  throw new IllegalStateException("total timeout must not be negative");
 }
 if (params.getInitialRetryDelay().toMillis() < 0) {
  throw new IllegalStateException("initial retry delay must not be negative");
 }
 if (params.getRetryDelayMultiplier() < 1.0) {
  throw new IllegalStateException("retry delay multiplier must be at least 1");
 }
 if (params.getMaxRetryDelay().compareTo(params.getInitialRetryDelay()) < 0) {
  throw new IllegalStateException("max retry delay must not be shorter than initial delay");
 }
 if (params.getMaxAttempts() < 0) {
  throw new IllegalStateException("max attempts must be non-negative");
 }
 if (params.getInitialRpcTimeout().toMillis() < 0) {
  throw new IllegalStateException("initial rpc timeout must not be negative");
 }
 if (params.getMaxRpcTimeout().compareTo(params.getInitialRpcTimeout()) < 0) {
  throw new IllegalStateException("max rpc timeout must not be shorter than initial timeout");
 }
 if (params.getRpcTimeoutMultiplier() < 1.0) {
  throw new IllegalStateException("rpc timeout multiplier must be at least 1");
 }
 return params;
}
origin: googleapis/gax-java

public RetrySettings build() {
 RetrySettings params = autoBuild();
 if (params.getTotalTimeout().toMillis() < 0) {
  throw new IllegalStateException("total timeout must not be negative");
 }
 if (params.getInitialRetryDelay().toMillis() < 0) {
  throw new IllegalStateException("initial retry delay must not be negative");
 }
 if (params.getRetryDelayMultiplier() < 1.0) {
  throw new IllegalStateException("retry delay multiplier must be at least 1");
 }
 if (params.getMaxRetryDelay().compareTo(params.getInitialRetryDelay()) < 0) {
  throw new IllegalStateException("max retry delay must not be shorter than initial delay");
 }
 if (params.getMaxAttempts() < 0) {
  throw new IllegalStateException("max attempts must be non-negative");
 }
 if (params.getInitialRpcTimeout().toMillis() < 0) {
  throw new IllegalStateException("initial rpc timeout must not be negative");
 }
 if (params.getMaxRpcTimeout().compareTo(params.getInitialRpcTimeout()) < 0) {
  throw new IllegalStateException("max rpc timeout must not be shorter than initial timeout");
 }
 if (params.getRpcTimeoutMultiplier() < 1.0) {
  throw new IllegalStateException("rpc timeout multiplier must be at least 1");
 }
 return params;
}
origin: googleapis/gax-java

@Override
public FakeCallContext withTimeout(Duration timeout) {
 // Default RetrySettings use 0 for RPC timeout. Treat that as disabled timeouts.
 if (timeout != null && (timeout.isZero() || timeout.isNegative())) {
  timeout = null;
 }
 // Prevent expanding timeouts
 if (timeout != null && this.timeout != null && this.timeout.compareTo(timeout) <= 0) {
  return this;
 }
 return new FakeCallContext(
   this.credentials,
   this.channel,
   timeout,
   this.streamWaitTimeout,
   this.streamIdleTimeout,
   this.extraHeaders,
   this.tracer);
}
origin: googleapis/gapic-generator

if (initialPollDelay.compareTo(Duration.ZERO) < 0) {
 diagCollector.addDiag(
   Diag.error(
if (maxPollDelay.compareTo(initialPollDelay) < 0) {
 diagCollector.addDiag(
   Diag.error(
if (totalPollTimeout.compareTo(maxPollDelay) < 0) {
 diagCollector.addDiag(
   Diag.error(
org.threeten.bpDurationcompareTo

Javadoc

Compares this duration to the specified Duration.

The comparison is based on the total length of the durations. It is "consistent with equals", as defined by Comparable.

Popular methods of Duration

  • ofMillis
    Obtains an instance of Duration from a number of milliseconds. The seconds and nanoseconds are extra
  • ofSeconds
    Obtains an instance of Duration from a number of seconds and an adjustment in nanoseconds. This meth
  • toMillis
    Converts this duration to the total length in milliseconds. If this duration is too large to fit in
  • ofMinutes
    Obtains an instance of Duration from a number of standard length minutes. The seconds are calculated
  • getSeconds
    Gets the number of seconds in this duration. The length of the duration is stored using two fields -
  • isZero
    Checks if this duration is zero length. A Duration represents a directed distance between two points
  • between
    Obtains an instance of Duration representing the duration between two instants. Obtains a Duration
  • getNano
    Gets the number of nanoseconds within the second in this duration. The length of the duration is sto
  • isNegative
    Checks if this duration is negative, excluding zero. A Duration represents a directed distance betwe
  • toNanos
    Converts this duration to the total length in nanoseconds expressed as a long. If this duration is
  • ofHours
    Obtains an instance of Duration from a number of standard length hours. The seconds are calculated b
  • ofNanos
    Obtains an instance of Duration from a number of nanoseconds. The seconds and nanoseconds are extrac
  • ofHours,
  • ofNanos,
  • equals,
  • of,
  • ofDays,
  • plus,
  • toMinutes,
  • <init>,
  • create

Popular in Java

  • Creating JSON documents from java classes using gson
  • getExternalFilesDir (Context)
  • setContentView (Activity)
  • putExtra (Intent)
  • GridBagLayout (java.awt)
    The GridBagLayout class is a flexible layout manager that aligns components vertically and horizonta
  • BufferedWriter (java.io)
    Wraps an existing Writer and buffers the output. Expensive interaction with the underlying reader is
  • SQLException (java.sql)
    An exception that indicates a failed JDBC operation. It provides the following information about pro
  • Date (java.util)
    A specific moment in time, with millisecond precision. Values typically come from System#currentTime
  • ExecutorService (java.util.concurrent)
    An Executor that provides methods to manage termination and methods that can produce a Future for tr
  • JFrame (javax.swing)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now