Posts Tagged: java 8

RxJava: Some Usage of Observable.zip

Posted by & filed under , .

Here’s  classic problem when dealing with a web app: you get a HTTP request to your app with a set of parameters. You need to hit a datastore to retrieve some record based on those parameters. You also need to create a (log?) entry somewhere about receiving this call — whether it’s for monitoring purposes […]

Scripting

Java, Map and Optional

Posted by & filed under , .

I do like the Optional class in Java — it is a long awaited elegant replacement for returning null whenever something isn’t there then relying on if( x != null ) checks or using ?: in the format (x == null) ? “foo” : “bar”. It works great also with the new Java stream classes […]

PMD Rules

Posted by & filed under , .

If you have used such plugins in your project as FindBugs, Checkstyle etc then you quite likely have heard of PMD too. (I have used these tools initially with Apache Maven and nowadays use them via Gradle in my builds, but there’s lots of support for others tools, Ant included.) The trouble with PMD as […]

Parallel : Groovy and Java Streams

Posted by & filed under .

This is something that every now and then I have to do: check whether either one or all elements of a collection meet a certain criteria. The standard code initially in Java involved a for loop and iterating through the collection explicitly and checking the condition at each step. Then Apache Commons came on with their […]

java code

Java … FunctionalInterface … WTF?

Posted by & filed under , .

If you’ve been doing “stuff” with Java 8 for a while I’m sure you’ve stepped into lambdas territory and the joys of succinct code it allows to be written. And if you are like me you probably found yourself using lambda’s everywhere you are confronted with a single-method interface. Which is allowed. In fact it’s […]

Why You Should Use Default Methods in Java 8 Interfaces

Posted by & filed under , .

With Java 8, Oracle introduced the concept of “default methods” in interfaces (and if you really haven’t heard of this — wtf?? — you can read more here about it: https://docs.oracle.com/javase/tutorial/java/IandI/defaultmethods.html). This argue some is a step towards multiple inheritance and as such should be banished from the oh, so pure! Java language. Others point out […]

Java Map and Subtleties of getOrDefault vs computeIfAbsent

Posted by & filed under , .

I wrote recently about the new niceties in the Map interface that Java 8 brought to light where I’m highlighting in particular 2 new methods: getOrDefault and computeIfAbsent (see my previous post here about it). These provide a cleaner (and as it turns out faster too!) way of retrieving values from a Map instance. However, […]

Java 8 — Map and the Unknown “Niceties”

Posted by & filed under , .

Despite Java 9 making its way into the real world nowadays, I see a lot of Java code out there still relying on the old-style Java 6-like syntax. And I’m not talking about the usage of lambda’s, stream’s and the likes, but rather some of the improvements Java 8 brought to existing classes in the […]

JAX London Logo

Of Java Streams … Again!

Posted by & filed under .

I just went again through this JAX London write-up (read more here: http://www.infoq.com/news/2015/10/jax-london-2015-round-up) and thought it was worth some more thoughts from me. As you might recall, I have touched before on the subject of Java 8 streams in this blog post back in Sep/2014. The thing that puzzled me back then was the fact […]

Find in Array — Java 8 Style

Posted by & filed under , , .

Java 8 has added support for parallel processing arrays — as I’m sure most of you know. There are lots of official release documents from Oracle talking about how employing these parallel methods and classes improves speed of your application — and as to be expected, there are lots of bloggers who set off to […]