Skip to content
Ben Yu edited this page Dec 23, 2023 · 17 revisions

Welcome to Mug, a small common library for Java 8 and above.

Why Mug when there's Guava?

The set of common utilties out of everyday needs of Java devs at Google created Guava. Much of that happened during Java 5 time, when the JDK had no immutable collections, no lambda, no Stream or Optional.

Fast forward to today, some of the needs of Java devs have shifted. You may be able to live without Guava's ImmutableList, ImmutableMap and just use List.of(), Map.of(). But chances are you could still find streaming Map.Entry awkard. And why can't common string manipulation be easier?

Mug intends to capture some of the recent common library evolution at Google, where you'll find some popular additions like BiStream, Substring and StringFormat.

We'll try to avoid reinventing wheels. If a utility is provided in Guava, you'll unlikely find it in Mug (with the exception of Walker, which offers a Stream-centric API similar to Guava's Iterable-based Traveser, and some extra functionalities).

Portability and API Stability

While Guava is a lot more versatile and portable, Mug focuses on Java 8+ (streams, optionals), and for JVM only. It doesn't compile for Java 7, and there is no guaranteed compatibility with other platforms like Android, or GWT.

Mug doesn't provide API stability guarantee as strongly as Guava, where non-Beta APIs are frozen and cannot change. Mug APIs may be deprecated as we see fit. In other words, all Mug APIs are implicitly @Beta.