Droid_Interceptor
Droid_Interceptor

Reputation: 663

Lombok Setter, set input variable to be final

Is is possible using lombok to set the input variable of a @Setter method to be final.

For example

public void setCarName(final String carName){
   this.carName = carName;
}

I don't know if this is even possible could not see it in the documentation.

Upvotes: 2

Views: 2070

Answers (3)

Remcoder
Remcoder

Reputation: 212

Why would you even be worried about this? Making it final only prevents you from reinitializing the variable, i.e. carName = "foo" or carName = new String("foo"). Since the code generated by lombok does not attempt to do this marking it as final is completely unneccesary.

Upvotes: 1

setec
setec

Reputation: 16110

It's not possible, just checked lombok sources.

Upvotes: 1

Andres
Andres

Reputation: 10725

Probably it's not possible.

The only advantage of making final this parameter is to improve readability, which makes no sense on code that will not be read.

Upvotes: 3

Related Questions