Java Tips: Process Object Based On Its Type Without if-then-else Solution

I want to share my answer for this question on StackOverflow. Say you want to process several objects with different types. Each type must be processed differently but some concerns are: You don’t want if-then-else solution which is obviously not great for long-term Configuration is also bad for the same reason So how is the …

Limit Your Access to Java API for More Productivity

Simplify your work environment to get more jobs done. One example here is to limit your access to the Java API so you won’t be distracted by proposals that you don’t need. RCP/SWT developers are facing this all the time. Point is a class in org.eclipse.swt.graphics, but it is also a class in java.awt. When …

Guava: Using ListenableFuture

Google Guava has many interesting classes which we can use on our application. The ones from collection package have been already used by many developers and this blog has tutorial on how to use the computing map. I want to move to the other package. This one is com.google.common.util.concurrent, specifically I want to introduce ListenableFuture. …

Java Tips: Initializing Collection

Especially in unit test, it is common case that we have to initialize an array or a collection. Well, for array, it’s OK… A simple code that we know can solve the problem: But how about Collection? Normal way to initialize collection is something like this (which pretty ugly): I hardly find an elegant solution …

Maven Plugin: Java Code Formatter

Enforcing code format in an organization needs discipline. And the best way to do that is by doing some automation. A plugin for Maven will be a easy decision if your organization has used Maven to manage the build. This plugin is one plugin that exactly does that. The backbone on the plugin comes from …

op4j: Bending the Java spoon

The tagline of op4j is very interesting: ‘Bending the Java spoon’, which implies that the library offer magic to Java programming. And indeed it does. The basic idea of the library is to use Fluent Interface to a much greater use. To do this, the developer basically try to provide as much general functions as …

Computing Map on Google Collections

Google always makes interesting projects. My toy nowadays is Google Collections. I don’t think I need to reintroduce it as it has been nicely covered on several blog posts: Introduction to Google Collections A series from CodeMunchies Beautiful code with Google Collections, Guava, and Static Imports Diving Into the Google Guava Library Functional Java Filtering …

Eclipse Tips: (Debugging) Ignoring certain classes from being stepped into

Some of us may have encountered a not so nice experience where you basically got an strange result from a method and decide to step into that method as deep as possible. The problem is somehow you are lost in track and you can’t debug furthermore except if you’re exiting the debug mode or resuming …