io.reactivex.functions.Function类的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(5.8k)|赞(0)|评价(0)|浏览(460)

本文整理了Java中io.reactivex.functions.Function类的一些代码示例,展示了Function类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Function类的具体详情如下:
包路径:io.reactivex.functions.Function
类名称:Function

Function介绍

[英]A functional interface that takes a value and returns another value, possibly with a different type and allows throwing a checked exception.
[中]一种函数接口,它接受一个值并返回另一个值,可能具有不同的类型,并允许抛出已检查的异常。

代码示例

代码示例来源: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 void accept(Map<K, T> m, T t) throws Exception {
    K key = keySelector.apply(t);
    m.put(key, t);
  }
}

代码示例来源:origin: ReactiveX/RxJava

@Override
  public ObservableSource<R> apply(Observable<T> t) throws Exception {
    ObservableSource<R> apply = ObjectHelper.requireNonNull(selector.apply(t), "The selector returned a null ObservableSource");
    return Observable.wrap(apply).observeOn(scheduler);
  }
}

代码示例来源: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

@Nullable
  @Override
  public U poll() throws Exception {
    T t = qs.poll();
    return t != null ? ObjectHelper.<U>requireNonNull(mapper.apply(t), "The mapper function returned a null value.") : null;
  }
}

代码示例来源:origin: ReactiveX/RxJava

@Override
  public Publisher<R> apply(Flowable<T> t) throws Exception {
    Publisher<R> p = ObjectHelper.requireNonNull(selector.apply(t), "The selector returned a null Publisher");
    return Flowable.fromPublisher(p).observeOn(scheduler);
  }
}

代码示例来源:origin: ReactiveX/RxJava

@Nullable
  @Override
  public U poll() throws Exception {
    T t = qs.poll();
    return t != null ? ObjectHelper.<U>requireNonNull(mapper.apply(t), "The mapper function returned a null value.") : null;
  }
}

代码示例来源: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 void onSuccess(T t) {
  ObservableSource<? extends R> o;
  try {
    o = ObjectHelper.requireNonNull(mapper.apply(t), "The mapper returned a null Publisher");
  } catch (Throwable ex) {
    Exceptions.throwIfFatal(ex);
    downstream.onError(ex);
    return;
  }
  o.subscribe(this);
}

代码示例来源:origin: ReactiveX/RxJava

@Override
public void onSuccess(T t) {
  Publisher<? extends R> p;
  try {
    p = ObjectHelper.requireNonNull(mapper.apply(t), "The mapper returned a null Publisher");
  } catch (Throwable ex) {
    Exceptions.throwIfFatal(ex);
    downstream.onError(ex);
    return;
  }
  p.subscribe(this);
}

代码示例来源:origin: ReactiveX/RxJava

@Override
public void onSuccess(T t) {
  ObservableSource<? extends R> o;
  try {
    o = ObjectHelper.requireNonNull(mapper.apply(t), "The mapper returned a null Publisher");
  } catch (Throwable ex) {
    Exceptions.throwIfFatal(ex);
    downstream.onError(ex);
    return;
  }
  o.subscribe(this);
}

代码示例来源:origin: ReactiveX/RxJava

@Override
  public Publisher<R> apply(final T t) throws Exception {
    @SuppressWarnings("unchecked")
    Publisher<U> u = (Publisher<U>)ObjectHelper.requireNonNull(mapper.apply(t), "The mapper returned a null Publisher");
    return new FlowableMapPublisher<U, R>(u, new FlatMapWithCombinerInner<U, R, T>(combiner, t));
  }
}

相关文章