where x.y.z represents the latest version
compile 'com.aol.cyclops:cyclops-guava:x.y.z'
<dependency>
<groupId>com.aol.cyclops</groupId>
<artifactId>cyclops-guava</artifactId>
<version>x.y.z</version>
</dependency>
- Native for comprehensions for Guava FluentIterable and Optional types
- Monad wrapping via AnyM / AnyMValue / AnyMSeq
- Compatible with cyclops-react pattern matching
- Ability to use Observables inside cyclops-react monad transformers (as the wrapping type, requires conversion to act as the nested type).
Currently requires Guava 19.0 or above
Use Guava. to create wrapped Guava Monads.
Optional in a for comprehension
Optional<Integer> optional = Guava.ForOptional.each2(Optional.of(10), a->Optional.absent(), (a,b)->"failed")
//Optional.absent
FluentIterable in a for comphrension
Guava.ForFluentIterable.each2(FluentIterable.from(ListX.of(1,2,3)),
a->FluentIterable.<Integer>from(ListX.of(a+10)),
Tuple::tuple).toString()
//[(1, 11), (2, 12), (3, 13)]
Subscribe to a Guava FluentIterable
import static com.aol.cyclops.javaslang.guava.fluentIterable;
SeqSubscriber<Integer> subscriber =SeqSubscriber.subscriber();
FluentIterable<Integer> stream = FluentIterable.from(Arrays.asList(1,2,3));
fluentIterable(stream).subscribe(subscriber);
subscriber.stream()
.forEachWithError(System.out::println, System.err::println);
Pacakage com.aol.cyclops.guava contains converters for types from various functional libraries for Java
- JDK
- Javaslang
- Functional Java
- jooλ
- simple-react
Supported Guava Monads include
- FluentIterable
- Optional
These are available in Cyclops Comprehensions, or via Cyclops AnyM.