Lombok: allow @Value to not create final classes

Created on 22 Jan 2016  路  7Comments  路  Source: projectlombok/lombok

Hi

when using a framework the final constraint can be quite intrusive so having a

@Value(useFinal=false)

would be very welcomed

Most helpful comment

As documented on the @Value page adding @NonFinal on the type gives you the desired behavior.

All 7 comments

It is impossible to guarantee that a non-final class is actually immutable, which is the whole point of @Value. Why not just use @Data?

@rschmitt agree, even the exact reason why @Value fails when used with such frameworks. Goal is mainly to not expose setters at all. @Data(readOnly=true) would work also but sounds better on @Value IMHO. Idea being to avoid to add yet another annotation (@Setter) on all "value" objects.

@NonFinal is already available.

Correct

As documented on the @Value page adding @NonFinal on the type gives you the desired behavior.

@rspilker does tht make the fields nonfinal too?

@rspilker does that make the fields nonfinal too?

It does not. Fields stay final.

Was this page helpful?
0 / 5 - 0 ratings