Open GoogleCodeExporter opened 9 years ago
Providing defaults as String, which is basically the only usable format, would
work for, well, Strings. Or other primitives for which a canonical way of
parsing a String is specified, and even that becomes unwieldy: what if the
specified default String does not represent a valid value?
Doing this for any other type of object is nearly impossible. Frankly, I don't
see this going to happen. Unless Reinier has some brilliant idea...
Original comment by askon...@gmail.com
on 2 Sep 2013 at 3:28
I guess this feature won't get classified as useful enough, but maybe I can
propose a better syntax:
class Crazy {
@AllowAssignmentInConstructor
private final double pi = Math.PI;
Crazy() {}
Crazy(double pi) {this.pi = pi;}
}
Lombok would remove the initializer expression and add an assignment to the
first ctor.
Original comment by Maaarti...@gmail.com
on 6 Sep 2013 at 12:54
@askoning: Is it okay if someone else has the brilliant idea?
Because what Maaartinus said, that'd work. Low on our priority list, though.
Original comment by reini...@gmail.com
on 10 Oct 2013 at 9:09
By all means. It looks more sane at the least :)
Original comment by askon...@gmail.com
on 10 Oct 2013 at 9:13
Maybe this is what the AllArgsConstructor should do, even without any
@AllowAssignmentInConstructor annotation. And maybe not: When somebody
specifies both a final field with an initializer and AllArgsConstructor, this
is probably an error.
The current behavior is that "All" means something like "all non-initialized
final fields". This contradicts the documentation stating that "An all-args
constructor requires one argument for every field in the class".
I guess the current behavior is fine and it's what people expect (despite the
prefix "All" being wrong). So I'd suggest to fix the documentation.
Original comment by Maaarti...@gmail.com
on 15 Oct 2013 at 8:30
Original issue reported on code.google.com by
venkates...@gmail.com
on 1 Sep 2013 at 8:14