本文整理了Java中java.time.Duration.isZero()
方法的一些代码示例,展示了Duration.isZero()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Duration.isZero()
方法的具体详情如下:
包路径:java.time.Duration
类名称:Duration
方法名:isZero
[英]Checks if this duration is zero length.
A Duration represents a directed distance between two points on the time-line and can therefore be positive, zero or negative. This method checks whether the length is zero.
[中]检查此持续时间是否为零长度。
持续时间表示时间线上两点之间的定向距离,因此可以为正、零或负。此方法检查长度是否为零。
代码示例来源:origin: thinkaurelius/titan
@Override
public boolean apply(@Nullable Duration sd) {
return null != sd && !sd.isZero();
}
});
代码示例来源:origin: thinkaurelius/titan
@Override
public void sleepFor(Duration duration) throws InterruptedException {
if (duration.isZero()) return;
TimeUnit.NANOSECONDS.sleep(duration.toNanos());
}
代码示例来源:origin: thinkaurelius/titan
public static final int getTTLSeconds(Duration duration) {
Preconditions.checkArgument(duration!=null && !duration.isZero(),"Must provide non-zero TTL");
long ttlSeconds = Math.max(1,duration.getSeconds());
assert ttlSeconds>0;
Preconditions.checkArgument(ttlSeconds<=Integer.MAX_VALUE, "tll value is too large [%s] - value overflow",duration);
return (int)ttlSeconds;
}
代码示例来源:origin: JanusGraph/janusgraph
@Override
public void sleepFor(Duration duration) throws InterruptedException {
if (duration.isZero()) return;
TimeUnit.NANOSECONDS.sleep(duration.toNanos());
}
代码示例来源:origin: JanusGraph/janusgraph
public static int getTTLSeconds(Duration duration) {
Preconditions.checkArgument(duration!=null && !duration.isZero(),"Must provide non-zero TTL");
long ttlSeconds = Math.max(1,duration.getSeconds());
assert ttlSeconds>0;
Preconditions.checkArgument(ttlSeconds<=Integer.MAX_VALUE, "tll value is too large [%s] - value overflow",duration);
return (int)ttlSeconds;
}
代码示例来源:origin: thinkaurelius/titan
private static final Duration pertubateTime(Duration duration) {
Duration newDuration = duration.dividedBy((int)(2.0 / (1 + (random.nextDouble() * 2 - 1.0) * PERTURBATION_PERCENTAGE)));
assert !duration.isZero() : duration;
return newDuration;
}
代码示例来源:origin: oracle/opengrok
@Override
public boolean isValid(final Duration duration, final ConstraintValidatorContext context) {
return duration != null && !duration.isNegative() && !duration.isZero();
}
}
代码示例来源:origin: oracle/opengrok
/**
* Sets the new duration for which to await the initialization of the suggester data. Does not affect already
* running initialization.
* @param awaitTerminationTime maximum duration for which to wait for initialization
*/
public final void setAwaitTerminationTime(final Duration awaitTerminationTime) {
if (awaitTerminationTime.isNegative() || awaitTerminationTime.isZero()) {
throw new IllegalArgumentException(
"Time to await termination of building the suggester data cannot be 0 or negative");
}
this.awaitTerminationTime = awaitTerminationTime;
}
代码示例来源:origin: wildfly/wildfly
@Override
public boolean isNew() {
// We can implement this more efficiently than the super implementation
return this.accessMetaData.getLastAccessedDuration().isZero();
}
代码示例来源:origin: lettuce-io/lettuce-core
@Override
public boolean isEnabled() {
return !options.eventEmitInterval().isZero() && scheduledFuture != null;
}
代码示例来源:origin: line/armeria
/**
* Sets the interval that a circuit breaker can see the latest accumulated count of events.
*/
public CircuitBreakerBuilder counterUpdateInterval(Duration counterUpdateInterval) {
requireNonNull(counterUpdateInterval, "counterUpdateInterval");
if (counterUpdateInterval.isNegative() || counterUpdateInterval.isZero()) {
throw new IllegalArgumentException(
"counterUpdateInterval: " + counterUpdateInterval + " (expected: > 0)");
}
this.counterUpdateInterval = counterUpdateInterval;
return this;
}
代码示例来源:origin: line/armeria
/**
* Sets the interval between health check requests. Must be positive.
*/
public HttpHealthCheckedEndpointGroupBuilder retryInterval(Duration retryInterval) {
requireNonNull(retryInterval, "retryInterval");
checkArgument(!retryInterval.isNegative() && !retryInterval.isZero(),
"retryInterval: %s (expected > 0)", retryInterval);
this.retryInterval = retryInterval;
return this;
}
代码示例来源:origin: JanusGraph/janusgraph
private static Duration pertubTime(Duration duration) {
Duration newDuration = duration.dividedBy((int)(2.0 / (1 + (random.nextDouble() * 2 - 1.0) * PERTURBATION_PERCENTAGE)));
assert !duration.isZero() : duration;
return newDuration;
}
代码示例来源:origin: atomix/atomix
/**
* Sets the base failure timeout.
*
* @param failureTimeout the base failure timeout
* @return the group membership configuration
*/
public SwimMembershipProtocolConfig setFailureTimeout(Duration failureTimeout) {
checkNotNull(failureTimeout, "failureTimeout cannot be null");
checkArgument(!failureTimeout.isNegative() && !failureTimeout.isZero(), "failureTimeout must be positive");
this.failureTimeout = checkNotNull(failureTimeout);
return this;
}
代码示例来源:origin: atomix/atomix
/**
* Sets the probe timeout.
*
* @param probeTimeout the probe timeout
* @return the membership protocol configuration
*/
public SwimMembershipProtocolConfig setProbeTimeout(Duration probeTimeout) {
checkNotNull(probeTimeout, "probeTimeout cannot be null");
checkArgument(!probeTimeout.isNegative() && !probeTimeout.isZero(), "probeTimeout must be positive");
this.probeTimeout = probeTimeout;
return this;
}
代码示例来源:origin: runelite/runelite
@Override
public boolean cull()
{
Duration timeLeft = Duration.between(Instant.now(), endTime);
return timeLeft.isZero() || timeLeft.isNegative();
}
代码示例来源:origin: wildfly/wildfly
@Override
public boolean isExpired() {
Duration maxInactiveInterval = this.getMaxInactiveInterval();
return !maxInactiveInterval.isZero() ? this.getLastAccessedTime().plus(maxInactiveInterval).isBefore(Instant.now()) : false;
}
}
代码示例来源:origin: line/armeria
/**
* Sets the timeout of a socket connection attempt.
*/
public ClientFactoryBuilder connectTimeout(Duration connectTimeout) {
requireNonNull(connectTimeout, "connectTimeout");
checkArgument(!connectTimeout.isZero() && !connectTimeout.isNegative(),
"connectTimeout: %s (expected: > 0)", connectTimeout);
return connectTimeoutMillis(connectTimeout.toMillis());
}
代码示例来源:origin: lettuce-io/lettuce-core
public DefaultCommandLatencyEventPublisher(EventExecutorGroup eventExecutorGroup, EventPublisherOptions options,
EventBus eventBus, CommandLatencyCollector commandLatencyCollector) {
this.eventExecutorGroup = eventExecutorGroup;
this.options = options;
this.eventBus = eventBus;
this.commandLatencyCollector = commandLatencyCollector;
if (!options.eventEmitInterval().isZero()) {
scheduledFuture = this.eventExecutorGroup.scheduleAtFixedRate(EMITTER, options.eventEmitInterval().toMillis(),
options.eventEmitInterval().toMillis(), TimeUnit.MILLISECONDS);
}
}
代码示例来源:origin: spring-projects/spring-security
@Override
public Mono<ClientResponse> filter(ClientRequest request, ExchangeFunction next) {
return next.exchange(withClientCookies(request))
.doOnSuccess( response -> {
response.cookies().values().forEach( cookies -> {
cookies.forEach( cookie -> {
if (cookie.getMaxAge().isZero()) {
this.cookies.remove(cookie.getName());
} else {
this.cookies.put(cookie.getName(), cookie);
}
});
});
});
}
内容来源于网络,如有侵权,请联系作者删除!