I’ve recently started working with Lombok, a really great project.

Image for post
Image for post
class Person {
private final String name;
private final String surname;
private final Date birth;
public Person(String name, String surname, Date birth) {
this.name = name;
this.surname = surname;
this.birth = birth;
}
public String getName() {
return this.name;
}
public String getSurname() {
return this.surname;
}
public Date getBirth() {
return this.birth;
}
public boolean equals(Object o) {
if (o == this) return true;
if (!(o instanceof Person)) return false;
final Person other = (Person) o;
return other.getName() == getName()
&& other.getSurname() == getSurname()
&& other.getBirth() == getBirth();
}
public String toString() {
return "Person(name=" + getName()
+ ", surname=" + getSurname()
+ ", birth=" + getBirth()
+ ")";
}
}
@Value
class Person {
private final String name;
private final String surname;
private final Date birth;
}
final HashMap<String, Integer> map = new HashMap<>();
val map = new HashMap<String, Integer>();

So… what’s wrong with Lombok?

Let’s take a look at Scala. The very same Person class:

case class Person(name: String, surname: String, birth: Date)

Written by

Musician, senior software engineer, autistic, and autistic parent (not necessarily in this order)

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store