本文整理了Java中io.reactivex.functions.Function.apply()
方法的一些代码示例,展示了Function.apply()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Function.apply()
方法的具体详情如下:
包路径:io.reactivex.functions.Function
类名称:Function
方法名:apply
[英]Apply some calculation to the input value and return some other value.
[中]对输入值应用一些计算并返回一些其他值。
代码示例来源:origin: ReactiveX/RxJava
@Override
public void accept(Map<K, V> m, T t) throws Exception {
K key = keySelector.apply(t);
V value = valueSelector.apply(t);
m.put(key, value);
}
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public Publisher<U> apply(T t) throws Exception {
return new FlowableFromIterable<U>(ObjectHelper.requireNonNull(mapper.apply(t), "The mapper returned a null Iterable"));
}
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public ObservableSource<U> apply(T t) throws Exception {
return new ObservableFromIterable<U>(ObjectHelper.requireNonNull(mapper.apply(t), "The mapper returned a null Iterable"));
}
}
代码示例来源:origin: ReactiveX/RxJava
@Nullable
@Override
public T poll() throws Exception {
for (;;) {
T v = qd.poll();
if (v == null || collection.add(ObjectHelper.requireNonNull(keySelector.apply(v), "The keySelector returned a null key"))) {
return v;
}
}
}
代码示例来源:origin: ReactiveX/RxJava
public <R, O> O x(Function<Publisher<T>, O> operator) {
try {
return operator.apply(onSubscribe);
} catch (Throwable ex) {
throw ExceptionHelper.wrapOrThrow(ex);
}
}
代码示例来源:origin: ReactiveX/RxJava
@Nullable
@Override
public U poll() throws Exception {
T t = qd.poll();
return t != null ? ObjectHelper.<U>requireNonNull(mapper.apply(t), "The mapper function returned a null value.") : null;
}
}
代码示例来源:origin: ReactiveX/RxJava
public <R> CylonDetectorObservable<? extends R> compose(Function<CylonDetectorObservable<? super T>, CylonDetectorObservable<? extends R>> transformer) {
try {
return transformer.apply(this);
} catch (Throwable ex) {
throw ExceptionHelper.wrapOrThrow(ex);
}
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public ObservableSource<R> apply(final T t) throws Exception {
@SuppressWarnings("unchecked")
ObservableSource<U> u = (ObservableSource<U>)ObjectHelper.requireNonNull(mapper.apply(t), "The mapper returned a null ObservableSource");
return new ObservableMap<U, R>(u, new FlatMapWithCombinerInner<U, R, T>(combiner, t));
}
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public void onSuccess(S value) {
Publisher<? extends T> f;
try {
f = ObjectHelper.requireNonNull(mapper.apply(value), "the mapper returned a null Publisher");
} catch (Throwable e) {
Exceptions.throwIfFatal(e);
downstream.onError(e);
return;
}
f.subscribe(this);
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public void onSuccess(T value) {
R v;
try {
v = ObjectHelper.requireNonNull(mapper.apply(value), "The mapper function returned a null value.");
} catch (Throwable e) {
Exceptions.throwIfFatal(e);
onError(e);
return;
}
t.onSuccess(v);
}
代码示例来源:origin: ReactiveX/RxJava
public SchedulerWhen(Function<Flowable<Flowable<Completable>>, Completable> combine, Scheduler actualScheduler) {
this.actualScheduler = actualScheduler;
// workers are converted into completables and put in this queue.
this.workerProcessor = UnicastProcessor.<Flowable<Completable>>create().toSerialized();
// send it to a custom combinator to pick the order and rate at which
// workers are processed.
try {
disposable = combine.apply(workerProcessor).subscribe();
} catch (Throwable e) {
throw ExceptionHelper.wrapOrThrow(e);
}
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public Publisher<T> apply(final T v) throws Exception {
Publisher<U> p = ObjectHelper.requireNonNull(itemDelay.apply(v), "The itemDelay returned a null Publisher");
return new FlowableTakePublisher<U>(p, 1).map(Functions.justFunction(v)).defaultIfEmpty(v);
}
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public void onError(Throwable t) {
R p;
try {
p = ObjectHelper.requireNonNull(onErrorMapper.apply(t), "The onError publisher returned is null");
} catch (Throwable e) {
Exceptions.throwIfFatal(e);
downstream.onError(new CompositeException(t, e));
return;
}
complete(p);
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public T next() {
if (--crashOnNext <= 0) {
throw new TestException("next()");
}
try {
return mapper.apply(count++);
} catch (Throwable ex) {
throw ExceptionHelper.wrapOrThrow(ex);
}
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public void onError(Throwable e) {
T v;
try {
v = ObjectHelper.requireNonNull(valueSupplier.apply(e), "The valueSupplier returned a null value");
} catch (Throwable ex) {
Exceptions.throwIfFatal(ex);
downstream.onError(new CompositeException(e, ex));
return;
}
downstream.onSuccess(v);
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public void onSuccess(T value) {
MaybeSource<? extends R> source;
try {
source = ObjectHelper.requireNonNull(onSuccessMapper.apply(value), "The onSuccessMapper returned a null MaybeSource");
} catch (Exception ex) {
Exceptions.throwIfFatal(ex);
downstream.onError(ex);
return;
}
source.subscribe(new InnerObserver());
}
代码示例来源:origin: ReactiveX/RxJava
@Test(expected = IllegalArgumentException.class)
public void toFunction3() throws Exception {
Functions.toFunction(new Function3<Integer, Integer, Integer, Integer>() {
@Override
public Integer apply(Integer t1, Integer t2, Integer t3) throws Exception {
return null;
}
}).apply(new Object[20]);
}
代码示例来源:origin: ReactiveX/RxJava
@Test(expected = IllegalArgumentException.class)
public void toFunction4() throws Exception {
Functions.toFunction(new Function4<Integer, Integer, Integer, Integer, Integer>() {
@Override
public Integer apply(Integer t1, Integer t2, Integer t3, Integer t4) throws Exception {
return null;
}
}).apply(new Object[20]);
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public void run() {
System.out.println(scheduler.now(TimeUnit.MILLISECONDS));
try {
calledOp.apply(scheduler.now(TimeUnit.MILLISECONDS));
} catch (Throwable ex) {
ExceptionHelper.wrapOrThrow(ex);
}
}
}, 1, 2, TimeUnit.SECONDS);
代码示例来源:origin: ReactiveX/RxJava
@Override
public void onError(Throwable e) {
MaybeSource<? extends R> source;
try {
source = ObjectHelper.requireNonNull(onErrorMapper.apply(e), "The onErrorMapper returned a null MaybeSource");
} catch (Exception ex) {
Exceptions.throwIfFatal(ex);
downstream.onError(new CompositeException(e, ex));
return;
}
source.subscribe(new InnerObserver());
}
内容来源于网络,如有侵权,请联系作者删除!