本文整理汇总了Java中io.reactivex.Maybe.just方法的典型用法代码示例。如果您正苦于以下问题:Java Maybe.just方法的具体用法?Java Maybe.just怎么用?Java Maybe.just使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.reactivex.Maybe
的用法示例。
在下文中一共展示了Maybe.just方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getThumbnails
import io.reactivex.Maybe; //导入方法依赖的package包/类
@Override
public Maybe<List<Photo>> getThumbnails(ContentResolver resolver) {
if (returnFailure){
return Maybe.empty();
} else {
List<Photo> list = new ArrayList<>();
for (int i = 0; i < 9; i++){
list.add(new Photo("photo-" + Integer.toString(i)));
}
return Maybe.just(list);
}
}
示例2: main
import io.reactivex.Maybe; //导入方法依赖的package包/类
public static void main(String[] args) {
// has emission
Maybe<Integer> presentSource = Maybe.just(100);
presentSource.subscribe(s -> System.out.println("Process 1 received:" + s),
Throwable::printStackTrace,
() -> System.out.println("Process 1 done!"));
//no emission
Maybe<Integer> emptySource = Maybe.empty();
emptySource.subscribe(s -> System.out.println("Process 2 received:" + s),
Throwable::printStackTrace,
() -> System.out.println("Process 2 done!"));
}
示例3: getProfile
import io.reactivex.Maybe; //导入方法依赖的package包/类
@Override
public Maybe<Profile> getProfile(String uid) {
if (returnFailure){
return Maybe.error(new Exception());
} else if (returnEmpty) {
return Maybe.empty();
}
//TODO: make static fake Profile for testing
return Maybe.just(fakeProfile);
}
示例4: getUser
import io.reactivex.Maybe; //导入方法依赖的package包/类
@Override
public Maybe<User> getUser() {
if (returnFailure){
return Maybe.error(new Exception());
}
//TODO: make static user for this test
return Maybe.just(fakeUser);
}
示例5: maybeFromNonNullItem
import io.reactivex.Maybe; //导入方法依赖的package包/类
private <R> Maybe<R> maybeFromNonNullItem(Function<T, R> flatMapper) {
R newItem = Invoker.invoke(flatMapper, chain.item);
if (newItem != null) {
return Maybe.just(newItem);
} else {
return Maybe.empty();
}
}
示例6: getSavedState
import io.reactivex.Maybe; //导入方法依赖的package包/类
/**
* Gets the current state as a Maybe. The Maybe will emit a single bundle if there is a previous state
* or if the state is missing it will emit no events and call the onComplete event
*/
@NonNull
public static Maybe<Bundle> getSavedState(@NonNull Activity activity) {
PreConditions.throwIfNotOnMainThread();
Bundle prevState = getSavedStateDirect(activity);
if(prevState != null) {
return Maybe.just(prevState);
} else {
return Maybe.empty();
}
}
示例7: getPokemonMaybeFromCache
import io.reactivex.Maybe; //导入方法依赖的package包/类
private Maybe<Pokemon> getPokemonMaybeFromCache() {
if (pokemonCache != null) {
return Maybe.just(pokemonCache);
} else {
return Maybe.empty();
}
}
示例8: apply
import io.reactivex.Maybe; //导入方法依赖的package包/类
@Override
public Maybe<Address> apply(@io.reactivex.annotations.NonNull List<Address> addresses) throws Exception {
return addresses.isEmpty() ? Maybe.<Address>empty() : Maybe.just(addresses.get(0));
}
示例9: Open
import io.reactivex.Maybe; //导入方法依赖的package包/类
public Open(Response response) {
this.response = Maybe.just(response);
}