RxJava-Optional
RxJava-Optional is an library that allows developers to use Optional using RxJava
Install
Download the latest JAR or grab via Gradle:
Gradle
repositories {
jcenter()
}
dependencies {
compile 'io.reactivex:rxandroid:0.24.0'
// compile 'io.reactivex:rxjava:1.0.5'
compile 'com.eccyan:rxjava-optional:1.1.0'
}
How to use
Optional<String> lastName = Optional.ofNullable("Daisuke");
Optional<String> firstName = Optional.ofNullable("Sato");
Optional<String> fullname =
lastName.flatMap(new Func1<String, Optional<String>>() {
@Override
public Optional<String> call(final String ln) {
return firstName.map(new Func1<String, String>() {
@Override
public String call(final String fn) {
return Strings.join(" ", ln, fn);
}
});
}
});
// With retrolambda
fullName = lastName.flatMap(ln -> firstName.map(fn -> Strings.join(" ", ln, fn)));
Developed By
Daisuke Sato(eccyan) - [email protected]
Thanks
-
Using RxJava
License
Copyright 2015 eccyan
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.