Wednesday, November 11, 2015

I like lombok

from
 public final class UserId {
     private final String userId;

    public UserId(String userId) {
        this.userId = userId;
    }

    public String getUserId() {
        return userId;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        UserId userId1 = (UserId) o;
        return !(userId != null ? !userId.equals(userId1.userId) : userId1.userId != null);
    }

    @Override
    public int hashCode() {
        return userId != null ? userId.hashCode() : 0;
    }

    @Override
    public String toString() {
        return "UserId{" + userId + '}';
    }
 }
to
import lombok.Data;

@Data
 public final class UserId {
     private final String userId;
 }
feels almost like scala...

No comments:

Post a Comment