Support projectlombok-like constructor annotations
These are the annotations I would like to port from projectlombok to xtend first:
- NoArgsConstructor, AllArgsConstructor, RequiredArgsConstructor, probably with a very similar API, so you can control constructor visibility, make it a static factory method, and set annotations to the constructor (e.g. @AutoWired or @Inject)
But let's discuss the idea and possible API before jumping to the implementation this time. :)
I think this is pretty well covered by Xtend's FinalFieldsConstructor (which is equivalent to RequiredArgsConstructor).
-
a
NoArgsConstructoris so short in Xtend (new() {}) that I don't think it makes sense to have an annotation for that -
an
AllArgsConstructorseems weird. Why would I take something in the constructor if it can be changed later? -
visibility, annotations etc. can be controlled by using this pattern:
class Foo { @Inject @FinalFieldsConstructor protected new() {} }
The AllArgsConstructor is not as useful in xtend as in java, I agree (because we have the with-initilizer => [] ) the lombok versions feature the possibility to be used as static factory methods. (e.g. Price.of(amount) instead of new Price(amount))
I'd rather have something like @FactoryMethod instead of an argument on the constructor annotation.