Use jOOλ’s Sneaky Throw to Avoid Checked Exceptions

Don't you hate how you have to wrap checked exception throwing code in static initialisers? E.g. you cannot write this in Java: public class Test { static final Class<?> klass = Class.forName("org.h2.Driver"); } There's an unhandled ClassNotFoundException, and you can't catch / rethrow it simply. A static initialiser is needed: public class Test { static … Continue reading Use jOOλ’s Sneaky Throw to Avoid Checked Exceptions

Lesser Known jOOλ Features: Useful Collectors

jOOλ is our second most popular library. It implements a set of useful extensions to the JDK's Stream API, which are useful especially when streams are sequential only, which according to our assumptions is how most people use streams in Java. Such extensions include: // (1, 2, 3, 1, 2, 3, 1, 2, 3, 1, … Continue reading Lesser Known jOOλ Features: Useful Collectors

Using jOOλ to Combine Several Java 8 Collectors into One

With Java 8 being mainstream now, people start using Streams for everything, even in cases where that's a bit exaggerated (a.k.a. completely nuts, if you were expecting a hyperbole here). For instance, take mykong's article here, showing how to collect a Map's entry set stream into a list of keys and a list of values: … Continue reading Using jOOλ to Combine Several Java 8 Collectors into One

Cyclops-react Organises the Cambrian Explosion of Java 8 Libraries

We’re excited to announce another very interesting guest post on the jOOQ Blog by John Mcclean from AOL. AOL is a global digital media and technology company, founded in 1985 and once known as America Online, AOL is now part of the Verizon Group. AOL focuses on four areas - video, mobile, ad technology and … Continue reading Cyclops-react Organises the Cambrian Explosion of Java 8 Libraries

How to Pattern-Match Files and Display Adjacent Lines in Java

Recently, we've published our article about the awesome window function support in jOOλ 0.9.9, which I believe is some of the best additions to the library that we've ever done. Today, we'll look into an awesome application of window functions in a use-case that is inspired by this Stack Overflow question Sean Nguyen: How to … Continue reading How to Pattern-Match Files and Display Adjacent Lines in Java

2016 Will be the Year Remembered as When Java Finally Had Window Functions!

You heard right. Up until now, the awesome window functions were a feature uniquely reserved to SQL. Even sophisticated functional programming languages still seem to lack this beautiful functionality (correct me if I'm wrong, Haskell folks). We've written tons of blog posts about window functions, evangelising them to our audience, in articles like: Probably the … Continue reading 2016 Will be the Year Remembered as When Java Finally Had Window Functions!

The Danger of Subtype Polymorphism Applied to Tuples

Java 8 has lambdas and streams, but no tuples, which is a shame. This is why we have implemented tuples in jOOλ - Java 8's missing parts. Tuples are really boring value type containers. Essentially, they're just an enumeration of types like these: public class Tuple2<T1, T2> { public final T1 v1; public final T2 … Continue reading The Danger of Subtype Polymorphism Applied to Tuples

How to use Java 8 Functional Programming to Generate an Alphabetic Sequence

I've stumbled upon an interesting Stack Overflow question by user "mip". The question was: I'm looking for a way of generating an alphabetic sequence: A, B, C, ..., Z, AA, AB, AC, ..., ZZ. This can be quickly recognised as the headings of an Excel spreadsheet, which does precisely that: . So far, none of … Continue reading How to use Java 8 Functional Programming to Generate an Alphabetic Sequence

Common SQL Clauses and Their Equivalents in Java 8 Streams

Functional programming allows for quasi-declarative programming in a general purpose language. By using powerful fluent APIs like Java 8's Stream API, or jOOλ's sequential Stream extension Seq or more sophisticated libraries like vavr or functionaljava, we can express data transformation algorithms in an extremely concise way. Compare Mario Fusco's imperative and functional version of the … Continue reading Common SQL Clauses and Their Equivalents in Java 8 Streams

How to Avoid the Dreaded Dead Lock when Pessimistic Locking – And some Awesome Java 8 Usage!

Sometimes you simply cannot avoid it: Pessimistic locking via SQL. In fact, it's an awesome tool when you want to synchronise several applications on a shared, global lock. Some may think this is abusing the database. We think use the tools you have if they can solve the problem you have. For instance, the RDBMS … Continue reading How to Avoid the Dreaded Dead Lock when Pessimistic Locking – And some Awesome Java 8 Usage!