Clone wiki

fugue / 3.0


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



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
Additionally the following utility methods have been added.
<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)
Iterables#mergeSorted includes a change to take a Comparator interface instead of the Guava Ordering interface
<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
## Inter operating with Guava and older versions of fugue

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
..., guavaFunction);
// would be migrated as follows using a method reference
..., guavaFunction::apply);
## Functions replaces Guava Functions Functions now hosts a builder for a function returning a constant and a function performing a map lookup with and without a default value.
<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)
##Supplier also gains memoize and weakMemoize These implementations come care of an external developer contributing to the project.
<A> Supplier<A> memoize(final Supplier<A> supplier)
<A> Supplier<A> weakMemoize(final Supplier<A> supplier)
## Either apply renamed to ap to be consistent with Option Apply is typically used as the name for the method used to combine a function inside a context with values inside a context.
<X> Either<L, X> ap(final Either<L, Function<R, X>> either)
## ScalaCoverters gains functions to transform between Java 8 types and Scala Longer term this code will be replaced by code in the Scala standard library. ## Either and Option lose long deprecated functions Either.merge, Either.cond, Either.getOrThrow, Either.sequenceRight/Left were deprecated in release 1.2. They are now removed. You can now find all of these methods on the Eithers class. Option.find and Option.filterNone were deprecated in 1.1 and are now removed. Find their replacements in Options. ## Throwables and Function2 are deprecated and the retry package has moved

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.