Can I exclude fields from lomboks @Data annotation?

You can do this by using the following annotations:

    @Getter(value=AccessLevel.NONE)
    @Setter(value=AccessLevel.NONE)
    private LocalDate dob;

It is also better to use a LocalDate instead of Date. Date is a deprecated API.

@pirho, your example still creates the getter and setter but makes them private.


I think this is the only way to hide:

@Getter(value=AccessLevel.PRIVATE)
@Setter(value=AccessLevel.PRIVATE)
private Date dob;

or maybe better with AccessLevel.NONE like Ken Chan's answer suggests

so overriding the access level. However this does not hide it from constructors.

Also you can make tricks with inheritance. Define class like:

public class Base {
    // @Getter if you want
    private Date dob;
}

and let your User to extend that:

@Data
public class User extends Base {
    private String first;
    private String last;
    private String email;
    private Boolean active;
}

Well , or better yet use AccessLevel.NONE to completely make it does not generate getter or setter. No private getter or setter will be generated.

@Getter(value=AccessLevel.NONE)
@Setter(value=AccessLevel.NONE)
private Date dob;