Tech Bits 'n' Pieces

Eliminate Java verbosity the easy way

Lombok is a Java Archive (JAR) file you can use to eliminate verbosity in Java code.

Consider, for example, a standard Java bean. A typical Java bean has several properties. Each property has an accessor and a mutator (getter and setter). There is also usually a toString() method, an equals() method, and a hashCode() method.

If you think about it, that seems like an awful lot of predictable redundancy. If it’s implied that each property has a getter and setter, and it usually is, why is it necessary to spell it out?

Enter Lombok. Lombok uses annotations to identify classes and blocks of Java code in an effort to eliminate lines of code. In the aforementioned Java bean example, all of the getters, setters, and the three other methods are implied and included at compile time.


  1. matthewpainter posted this
To Tumblr, Love Metalab