Wiki
Clone wikifugue / 3.0
Summary
This release represents the breaking change necessary to remove Guava and support Java 8. Use this version of fugue for any projects starting now with Java 8.
- No more Guava, no more dependencies of any kind in the base io.atlassian.fugue package
- All usage of Fugue and Guava functional interfaces have been replaced with their Java 8 equivalents
- Large additions made to Iterables to sever the usage link with Guava. Fugue Iterables is now mostly a super set of Guava Iterables
- Released on Maven Central using the central-pom. This project now releases straight to maven central and no longer requires the atlassian
Issues
- Auc should be a compile scope dependency
- Newbie Support: Fork, clone, mvn clean install fails
- Fugue migration boiler plate
- Publish fugue 3.0 Milestone / Beta release / Track the migration process from 2.4 - 3.0
- Move v3 to be under another package
- Support more of the functions from guava iterables
- usage of Guava and Fugue requires imports with FQN
- Question about Either.Projection.apply
- Compilation error due to ambiguous getOrElse on a lambda(See explanation)
- Javadoc not published to atlassian site
- Android support
Changes
No, as in zero, external dependencies
All transitive dependencies have been removed from the fugue module. In addition to removing Guava com.atlassian.util.concurrent, slf4j, and jsr305 were also removed.
Fugue Iterables can properly replace Guava Iterables
Iterables added implementations of the transformation functions you'd expect. There is no intention to replace the rest of Guava's collections code.
<A> Iterable<A> filter(final Iterable<A> as, final Predicate<? super A> p) <A, B> Iterable<B> map(final Iterable<A> as, final Function<? super A, ? extends B> f) <A, B> Iterable<B> transform(final Iterable<A> as, final Function<? super A, ? extends B> f) // deprecated at point of addition useful only for migration as a proxy for map
<A> boolean addAll(final Collection<A> collectionToModify, final Iterable<? extends A> elementsToAdd) <A> Iterable<A> concat(final Iterable<? extends A>... as) <A> Iterable<A> cycle(final A... as) <A> Iterable<A> join(final Iterable<? extends Iterable<? extends A>> ias) <A> String makeString(final Iterable<? extends A> as, final String start, final String sep, final String end, final int maxLength) <A> int size(final Iterable<A> as) <A> Iterable<A> takeWhile(final Iterable<A> as, final Predicate<A> p) <A> Iterable<A> dropWhile(final Iterable<A> as, final Predicate<A> p)
<A extends Comparable<A>> Iterable<A> mergeSorted(final Iterable<? extends Iterable<A>> xss, final Comparator<A> ordering)
Options gain interoperability with Java 8 Optional
The Option class can be converted directly to or from a Java 8 optional. Options gains an additional function that wraps the output of a null producing function to return a function resulting in an Option. Optional toOptional()
##Java 8 generics and function interface inference fix Added a new version of getOrElse that fixes a new conflict in overloaded method resolution introduced in Java 8 Compilation error due to ambiguous getOrElse on a lambda. Functional functions overloaded with both a generic type and a functional interface result in an ambiguous method resolution. It can be fixed via an explicit cast. In this case a new function was introduced to avoid ambiguity.
A getOr(final Supplier<? extends A> supplier) // new signature A getOrElse(final Supplier<? extends A> supplier) // deprecated ambiguous signature
The boiler plate for convertering between fugue v2 and v3 can be found on Bitbucket. With Java 8 the simplest way to migrate code using older functional interfaces is to add a method reference to the function you require.
// fugue version two code ... Iterables.map(someIterable, guavaFunction); // would be migrated as follows using a method reference ... Iterables.map(someIterable, guavaFunction::apply);
<A, B> Function<A, B> constant(final B constant) <A, B> Function<A, Option<B>> forMap(final Map<A, B> map) <A, B> Function<A, B> forMapWithDefault(final Map<A, B> map, final B defaultValue)
<A> Supplier<A> memoize(final Supplier<A> supplier) <A> Supplier<A> weakMemoize(final Supplier<A> supplier)
<X> Either<L, X> ap(final Either<L, Function<R, X>> either)
io.atlassian.fugue.retry is now member of the fugua-guava maven module. This new module also contains Function2, Throwables, and ImmutableMaps. Fugue-guava is intended for any code that needs to bring an external dependency to compile. For the most part this is any code that wants to inter operate with Guava.
Updated