Understanding Guava Lists.transform()

Guava is a wonderful library by Google. Before Java 8 Guava was one of the best ways to use functional programming in Java. I’ve being using Guava in one of my projects and came accross an strance issue reasontly. I had a list of items and I wanted to convert them to different object and filter some of those items. After filtering I was changing some values in the list items. »

Easy way to Mock REST services

These days we are working more and more with REST web services. Most of the times we are writing clients to access 3rd party sevices hosted in a remote server or even local services. Sometimes in large teams one group is developing the server and other group is writing the clients to use them. In such situations client team might need to test their clients without the availablity of the real service. »

Caution with Java Autoboxing

In Java Boxing means when you convert a primitive type to a reference type. So when you have some thing like boolean myBool = new Boolean("true"); Boolean object is converted to primitive type boolean. So how this happens under the hood? Java compiler uses the method booleanValue() in Boolean class to get the primitive value. This is where you have to be careful; there is a possibility of NPE when the Boolean object is null. »