how to use lombok singular different

how to use lombok singular different

Problem Description:

@Data
@Builder
public class CarViews {
    @Singular("carViewList")
    private List<CarResponse> carViewList;
}
private CarViews prepareCarList() {
    CarResponse carResponse = CarResponse.builder().build();
    return CarViews.builder().carViewList(carResponse).build();
}

I am using singular like this, is that using right?
Should I use it differently?

It does not return error, it works, but I wonder, is this using right?

Solution – 1

It’s intended to be used like this:

@Data
@Builder
public class CarViews {
    @Singular
    private List<CarResponse> cars;
}

Lombok will automatically recognize the plural, and add a car method to the builder that’ll allow you to add single CarResponse objects.

For details, see the documentation.

Rate this post
We use cookies in order to give you the best possible experience on our website. By continuing to use this site, you agree to our use of cookies.
Accept
Reject