akshattandon / projectlombok

Automatically exported from code.google.com/p/projectlombok
0 stars 0 forks source link

@lombok.Value ignores @NonFinal with part "@RequiredArgsConstructor" #769

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
@lombok.Value
public class Pojo {
  String s1;
  @lombok.experimental.NonFinal String s2;
}

What is the expected output? What do you see instead?
exp. constructor: public Pojo(String s1){...}
act. constructor: public Pojo(String s1, String s2){...}

What version of the product are you using? On what operating system?
1.14.8, eclipse 4.4

Original issue reported on code.google.com by ralfw...@gmail.com on 14 Jan 2015 at 1:27

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
resolved, see: https://github.com/tgerder/lombok

Original comment by ralfw...@gmail.com on 14 Jan 2015 at 6:21

GoogleCodeExporter commented 9 years ago
The spec of @Value is explicit in saying that it implies @AllArgsConstructor. 
We could discuss if this is a sensible default, but I posit that it is a mostly 
irrelevant exotic detail that's not worth the time it would take to discuss it 
in detail.

Furthermore even if defaulting to @RequiredArgsConstructor would be a better 
idea than defaulting to @AllArgsConstructor, the difference is so tiny, it'll 
never even get close to crossing the bar required to make a backwards 
incompatible change to the specification at this point in time. Therefore, the 
discussion is definitely not worth having.

Enhancement request therefore denied.

NB: I don't know enough about the Pojo you are making to be sure, but there are 
3 alternate routes to solve your problem:

* Perhaps @Data is more appropriate than @Value, here.

* If s2 is a transient-style internal cache fields, consider naming it '$s2' 
instead; that way, lombok ignores it entirely; it will not be included in the 
constructor, and no getter will be generated for it. hashCode and equals and 
toString will also all ignore it.

* Just write '@lombok.Value @lombok.RequiredArgsConstructor', that works fine.

Original comment by reini...@gmail.com on 29 Jan 2015 at 7:53