Next Steps to Pattern Matching in Java with Java 12 and Switch Expressions aka JEP 325

It is interesting to see how the Java language evolves over time. One thing that I have always missed is pattern matching in a way similar to languages like Scala. Now there are different JDK Enhancement Proposals (JEP) aiming at bringing us a little bit closer to pattern matching, especially JEP 325 aka Switch Expressions that are included in the current Java 12 preview or JEP 305 aka Pattern Matching for instanceof. ...

December 30, 2018 · 4 min · 715 words · Micha Kops

Using Deferred Objects and Promises with Java 8 and JDeferred

Promises may help us when dealing with asynchronous code and we need to merge, pipe or track the progress and the results of single parts of computation in our applications. In the following tutorial I’d like to demonstrate a small library, JDeferred that helps us for this specific use case. Figure 1. JDeferred examples running in Eclipse IDE. Dependencies Using Maven here, we simply need to add one dependency for jdeferred-core to our pom.xml: ...

September 27, 2015 · 8 min · 1631 words · Micha Kops

Playing with Java 8 Lambda Expressions

Many articles have been written about JSR 335 aka Lambda Expressions for the JavaTM Programming Language but I like to try new things out for myself and that’s why I’d like to share my snippets here. Figure 1. Lambda Hacking using the NetBeans Developer Version Setup JDK and IDE It takes just some short steps to setup your environment … Download and install the Java 8 JDK with lambda support Download and install the NetBeans IDE Development version Configure NetBeans to use the Java 8 JDK (> Manage Platforms…) ...

September 22, 2013 · 5 min · 1012 words · Micha Kops

Aspects of Functional Programming in Java

Functional programming is a trending topic these days and a lot of Java programmers are hot for the features that modern functional programming languages might offer. Waiting for Java 8 and native closure support is a nice thing but for now we’re going to take a look at several Java frameworks that are trying to implement typical structures from those functional languages where possible using the capabilities of the Java language to emulate elements like higher-order-functions, closures, options and others … ...

July 16, 2012 · 16 min · 3233 words · Micha Kops

Snippet: Mixing Scala, Java in a Maven Project

Having just returned from the Atlassian Camp 2012 I just toyed around with Java and Scala and wanted to share the following snippet that demonstrates how to mix code from both languages in a Maven project using the maven-scala-plugin. Setting up the Maven Project First create a new Maven project in your IDE or by running mvn archetype:generate. In the next step, add the dependency for scala-library and the scala maven repositories to your pom.xml and hook the maven-scala-plugin to Maven’s lifecycle. My pom.xml finally looks like this one: ...

March 23, 2012 · 2 min · 327 words · Micha Kops