本文整理了Java中java.time.Duration.equals()
方法的一些代码示例,展示了Duration.equals()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Duration.equals()
方法的具体详情如下:
包路径:java.time.Duration
类名称:Duration
方法名:equals
[英]Checks if this duration is equal to the specified Duration.
The comparison is based on the total length of the durations.
[中]检查此持续时间是否等于指定的持续时间。
比较基于持续时间的总长度。
代码示例来源:origin: bootique/bootique
@Override
public boolean equals(Object obj) {
if (obj instanceof Duration) {
return duration.equals(((Duration) obj).duration);
}
return false;
}
代码示例来源:origin: ehcache/ehcache3
@Override
public boolean equals(Object obj) {
return obj instanceof TimeToIdleExpiryPolicy && tti.equals(((TimeToIdleExpiryPolicy) obj).tti);
}
代码示例来源:origin: ehcache/ehcache3
@Override
public boolean equals(Object obj) {
return obj instanceof TimeToLiveExpiryPolicy && ttl.equals(((TimeToLiveExpiryPolicy) obj).ttl);
}
代码示例来源:origin: ehcache/ehcache3
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Timeouts timeouts = (Timeouts) o;
if (!readOperationTimeout.equals(timeouts.readOperationTimeout)) {
return false;
}
if (!writeOperationTimeout.equals(timeouts.writeOperationTimeout)) {
return false;
}
return connectionTimeout.equals(timeouts.connectionTimeout);
}
代码示例来源:origin: apache/geode
/**
* Sets a callable to be repeated the given number of times. If there is also an expected result
* for the callable, that expectation must be met for each iteration of the callable.
*
* @param iterations the number of times to run the callable
* @return this, the ConcurrentOperation (containing a callable) that has been set to repeat
*/
public ConcurrentOperation repeatForIterations(int iterations) {
if (!duration.equals(DEFAULT_DURATION)) {
throw new IllegalArgumentException("Specify only Duration or Iterations");
}
this.iterations = iterations;
return this;
}
代码示例来源:origin: ehcache/ehcache3
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
LatencyHistogramConfiguration that = (LatencyHistogramConfiguration) o;
if (that.phi != phi) return false;
if (bucketCount != that.bucketCount) return false;
return window.equals(that.window);
}
代码示例来源:origin: ehcache/ehcache3
private static TimeType convertToTimeType(Duration duration) {
return Stream.of(java.util.concurrent.TimeUnit.values())
.sorted(comparing(unit -> unit.convert(duration.toNanos(), NANOSECONDS)))
.filter(unit -> duration.equals(Duration.of(unit.convert(duration.toNanos(), NANOSECONDS), jucTimeUnitToTemporalUnit(unit))))
.findFirst()
.map(unit -> new TimeType()
.withValue(BigInteger.valueOf(unit.convert(duration.toNanos(), NANOSECONDS)))
.withUnit(convertToXmlTimeUnit(unit))
).orElseThrow(AssertionError::new);
}
}
代码示例来源:origin: ehcache/ehcache3
protected static <K, V> boolean newValueAlreadyExpired(Logger logger, ExpiryPolicy<? super K, ? super V> expiry, K key, V oldValue, V newValue) {
if (newValue == null) {
return false;
}
Duration duration;
try {
if (oldValue == null) {
duration = expiry.getExpiryForCreation(key, newValue);
} else {
duration = expiry.getExpiryForUpdate(key, () -> oldValue, newValue);
}
} catch (RuntimeException re) {
logger.error("Expiry computation caused an exception - Expiry duration will be 0 ", re);
return true;
}
return Duration.ZERO.equals(duration);
}
代码示例来源:origin: ehcache/ehcache3
private static <K, V> boolean newValueAlreadyExpired(Logger logger, ExpiryPolicy<? super K, ? super V> expiry, K key, V oldValue, V newValue) {
if (newValue == null) {
return false;
}
Duration duration;
try {
if (oldValue == null) {
duration = expiry.getExpiryForCreation(key, newValue);
} else {
duration = expiry.getExpiryForUpdate(key, () -> oldValue, newValue);
}
} catch (RuntimeException re) {
logger.error("Expiry computation caused an exception - Expiry duration will be 0 ", re);
return true;
}
return Duration.ZERO.equals(duration);
}
}
代码示例来源:origin: ehcache/ehcache3
@Override
public void setAccessAndExpiryTimeWhenCallerOutsideLock(K key, OnHeapValueHolder<V> valueHolder, long now) {
Duration duration = getAccessDuration(key, valueHolder);
if (Duration.ZERO.equals(duration)) {
// Expires mapping through computeIfPresent
store.expireMappingUnderLock(key, valueHolder);
} else {
valueHolder.accessed(now, duration);
}
}
代码示例来源:origin: ehcache/ehcache3
public OnHeapValueHolder<V> setAccessAndExpiryWhenCallerlUnderLock(K key, OnHeapValueHolder<V> valueHolder, long now,
StoreEventSink<K, V> eventSink) {
Duration duration = getAccessDuration(key, valueHolder);
if (Duration.ZERO.equals(duration)) {
// Fires event, must happen under lock
store.fireOnExpirationEvent(key, valueHolder, eventSink);
return null;
} else {
valueHolder.accessed(now, duration);
}
return valueHolder;
}
代码示例来源:origin: ehcache/ehcache3
private OffHeapValueHolder<V> setAccessTimeAndExpiryThenReturnMapping(K key, OffHeapValueHolder<V> valueHolder, long now, StoreEventSink<K, V> eventSink) {
Duration duration = Duration.ZERO;
try {
duration = expiry.getExpiryForAccess(key, valueHolder);
if (duration != null && duration.isNegative()) {
duration = Duration.ZERO;
}
} catch (RuntimeException re) {
LOG.error("Expiry computation caused an exception - Expiry duration will be 0 ", re);
}
if (Duration.ZERO.equals(duration)) {
onExpiration(key, valueHolder, eventSink);
return null;
}
valueHolder.accessed(now, duration);
valueHolder.writeBack();
return valueHolder;
}
代码示例来源:origin: ehcache/ehcache3
private OnHeapValueHolder<V> importValueFromLowerTier(K key, ValueHolder<V> valueHolder, long now, Backend<K, V> backEnd, Fault<V> fault) {
Duration expiration = strategy.getAccessDuration(key, valueHolder);
if (Duration.ZERO.equals(expiration)) {
invalidateInGetOrComputeIfAbsent(backEnd, key, valueHolder, fault, now, Duration.ZERO);
getOrComputeIfAbsentObserver.end(CachingTierOperationOutcomes.GetOrComputeIfAbsentOutcome.FAULT_FAILED);
return null;
}
try{
return cloneValueHolder(key, valueHolder, now, expiration, true);
} catch (LimitExceededException e) {
LOG.warn(e.getMessage());
invalidateInGetOrComputeIfAbsent(backEnd, key, valueHolder, fault, now, expiration);
getOrComputeIfAbsentObserver.end(CachingTierOperationOutcomes.GetOrComputeIfAbsentOutcome.FAULT_FAILED);
return null;
}
}
代码示例来源:origin: reactor/reactor-core
if (bufferingTimespan.equals(openBufferEvery)) {
return buffer(bufferingTimespan, timer);
代码示例来源:origin: reactor/reactor-core
if (openWindowEvery.equals(windowingTimespan)) {
return window(windowingTimespan);
代码示例来源:origin: ehcache/ehcache3
private OnHeapValueHolder<V> newUpdateValueHolder(K key, OnHeapValueHolder<V> oldValue, V newValue, long now, StoreEventSink<K, V> eventSink) {
Objects.requireNonNull(oldValue);
Objects.requireNonNull(newValue);
Duration duration = strategy.getUpdateDuration(key, oldValue, newValue);
if (Duration.ZERO.equals(duration)) {
eventSink.updated(key, oldValue, newValue);
eventSink.expired(key, () -> newValue);
return null;
}
long expirationTime;
if (duration == null) {
expirationTime = oldValue.expirationTime();
} else {
if (isExpiryDurationInfinite(duration)) {
expirationTime = ValueHolder.NO_EXPIRE;
} else {
expirationTime = ExpiryUtils.getExpirationMillis(now, duration);
}
}
OnHeapValueHolder<V> holder = null;
try {
holder = makeValue(key, newValue, now, expirationTime, this.valueCopier);
eventSink.updated(key, oldValue, newValue);
} catch (LimitExceededException e) {
LOG.warn(e.getMessage());
eventSink.removed(key, oldValue);
}
return holder;
}
代码示例来源:origin: google/error-prone
if (converter.reverse().convert(nextValue).equals(duration)) {
代码示例来源:origin: ehcache/ehcache3
private OffHeapValueHolder<V> newUpdatedValueHolder(K key, V value, OffHeapValueHolder<V> existing, long now, StoreEventSink<K, V> eventSink) {
eventSink.updated(key, existing, value);
Duration duration = Duration.ZERO;
try {
duration = expiry.getExpiryForUpdate(key, existing, value);
if (duration != null && duration.isNegative()) {
duration = Duration.ZERO;
}
} catch (RuntimeException re) {
LOG.error("Expiry computation caused an exception - Expiry duration will be 0 ", re);
}
if (Duration.ZERO.equals(duration)) {
eventSink.expired(key, () -> value);
return null;
}
if (duration == null) {
return new BasicOffHeapValueHolder<>(backingMap().nextIdFor(key), value, now, existing.expirationTime());
} else if (isExpiryDurationInfinite(duration)) {
return new BasicOffHeapValueHolder<>(backingMap().nextIdFor(key), value, now, OffHeapValueHolder.NO_EXPIRE);
} else {
return new BasicOffHeapValueHolder<>(backingMap().nextIdFor(key), value, now, ExpiryUtils.getExpirationMillis(now, duration));
}
}
代码示例来源:origin: thinkaurelius/titan
Preconditions.checkState(true == ALLOW_STALE_CONFIG.getDefaultValue());
Preconditions.checkState(ALLOW_STALE_CONFIG.getType().equals(ConfigOption.Type.MASKABLE));
Preconditions.checkState(!customCommitTime.equals(MAX_COMMIT_TIME.getDefaultValue()));
代码示例来源:origin: JanusGraph/janusgraph
Preconditions.checkState(ALLOW_STALE_CONFIG.getDefaultValue());
Preconditions.checkState(ALLOW_STALE_CONFIG.getType().equals(ConfigOption.Type.MASKABLE));
Preconditions.checkState(!customCommitTime.equals(MAX_COMMIT_TIME.getDefaultValue()));
内容来源于网络,如有侵权,请联系作者删除!