本文整理汇总了Java中com.github.davidmoten.guavamini.Optional类的典型用法代码示例。如果您正苦于以下问题:Java Optional类的具体用法?Java Optional怎么用?Java Optional使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Optional类属于com.github.davidmoten.guavamini包,在下文中一共展示了Optional类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startScheduledResetAgain
import com.github.davidmoten.guavamini.Optional; //导入依赖的package包/类
private static <T> void startScheduledResetAgain(final long duration, final TimeUnit unit,
final Scheduler scheduler, final AtomicReference<CachedObservable<T>> cacheRef,
final AtomicReference<Optional<Scheduler.Worker>> workerRef) {
Runnable action = new Runnable() {
@Override
public void run() {
cacheRef.get().reset();
}
};
// CAS loop to cancel the current worker and create a new one
while (true) {
Optional<Scheduler.Worker> wOld = workerRef.get();
if (wOld == null) {
// we are finished
return;
}
Optional<Scheduler.Worker> w = Optional.of(scheduler.createWorker());
if (workerRef.compareAndSet(wOld, w)) {
if (wOld.isPresent())
wOld.get().dispose();
w.get().schedule(action, duration, unit);
break;
}
}
}
示例2: startScheduledResetAgain
import com.github.davidmoten.guavamini.Optional; //导入依赖的package包/类
private static <T> void startScheduledResetAgain(final long duration, final TimeUnit unit,
final Scheduler scheduler, final AtomicReference<CachedFlowable<T>> cacheRef,
final AtomicReference<Optional<Scheduler.Worker>> workerRef) {
Runnable action = new Runnable() {
@Override
public void run() {
cacheRef.get().reset();
}
};
// CAS loop to cancel the current worker and create a new one
while (true) {
Optional<Scheduler.Worker> wOld = workerRef.get();
if (wOld == null) {
// we are finished
return;
}
Optional<Scheduler.Worker> w = Optional.of(scheduler.createWorker());
if (workerRef.compareAndSet(wOld, w)) {
if (wOld.isPresent())
wOld.get().dispose();
w.get().schedule(action, duration, unit);
break;
}
}
}
示例3: pollInterval
import com.github.davidmoten.guavamini.Optional; //导入依赖的package包/类
public WatchEventsBuilder pollInterval(long interval, TimeUnit unit) {
this.pollInterval = interval;
this.pollIntervalUnit = unit;
if (!pollDuration.isPresent())
this.pollDuration = Optional.of(0L);
return this;
}
示例4: pollDuration
import com.github.davidmoten.guavamini.Optional; //导入依赖的package包/类
public WatchEventsBuilder pollDuration(long duration, TimeUnit unit) {
this.pollDuration = Optional.of(duration);
this.pollDurationUnit = unit;
return this;
}