本文整理匯總了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);
}
}