本文整理汇总了Java中io.reactivex.functions.Function.apply方法的典型用法代码示例。如果您正苦于以下问题:Java Function.apply方法的具体用法?Java Function.apply怎么用?Java Function.apply使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.reactivex.functions.Function
的用法示例。
在下文中一共展示了Function.apply方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: apply
import io.reactivex.functions.Function; //导入方法依赖的package包/类
/**
* Applies a function to the current value, emitting the new returned value.
* <p>
* The function should fast to take less synchronized time.
*/
public void apply(Function<T, T> func) {
synchronized (this) {
try {
value = func.apply(value);
for (ObservableEmitter<T> emitter : emitters) {
queue.add(new Entry<>(emitter, value));
}
} catch (Exception e) {
throw propagate(e);
}
}
emit();
}
示例2: apply
import io.reactivex.functions.Function; //导入方法依赖的package包/类
static <T, R> R apply(Function<T, R> f, T t) {
try {
return f.apply(t);
} catch (Throwable ex) {
throw Exceptions.propagate(ex);
}
}
示例3: flatMapIfPresent
import io.reactivex.functions.Function; //导入方法依赖的package包/类
@Nonnull
public <R> RxOptional<R> flatMapIfPresent(@Nonnull Function<T, RxOptional<R>> function) {
if (value != null) {
requireNonNull(function);
try {
return function.apply(value);
} catch (Exception e) {
e.printStackTrace();
}
}
return empty();
}
示例4: onSchedule
import io.reactivex.functions.Function; //导入方法依赖的package包/类
public static Runnable onSchedule(Runnable run) {
Function<Runnable, Runnable> f = onSchedule;
if (f == null) {
return run;
}
try {
return f.apply(run);
} catch (Throwable ex) {
throw ExceptionHelper.wrapOrThrow(ex);
}
}
示例5: onEdtScheduler
import io.reactivex.functions.Function; //导入方法依赖的package包/类
public static Scheduler onEdtScheduler(Scheduler original) {
Function<Scheduler, Scheduler> f = onEdtScheduler;
if (f == null) {
return original;
}
try {
return f.apply(original);
} catch (Throwable ex) {
throw ExceptionHelper.wrapOrThrow(ex);
}
}
示例6: onAssembly
import io.reactivex.functions.Function; //导入方法依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
public static <T> Observable<T> onAssembly(Observable<T> original) {
Function<Observable, Observable> f = onAssembly;
if (f == null) {
return original;
}
try {
return f.apply(original);
} catch (Throwable ex) {
throw ExceptionHelper.wrapOrThrow(ex);
}
}
示例7: funcapply
import io.reactivex.functions.Function; //导入方法依赖的package包/类
private static <T, R> R funcapply(Function<T, R> f, T val) throws Exception {
return f.apply(val);
}
示例8: preapply
import io.reactivex.functions.Function; //导入方法依赖的package包/类
private static <T, R> Callable<R> preapply(Function<T, R> func, T inst) {
return () -> func.apply(inst);
}
示例9: invoke
import io.reactivex.functions.Function; //导入方法依赖的package包/类
/**
* invoke a {@link Function} or throw a {@link RuntimeException}
*
* @param function the {@link Function} to invoke
* @param parameter the parameter passed
* @param <T> the type of the parameter
* @param <R> the type of the return
* @return the result of the invocation
*/
static <T, R> R invoke(Function<T, R> function, T parameter) {
try {
return function.apply(parameter);
} catch (Exception e) {
throw new RuntimeExceptionConverter().apply(e);
}
}