Creating annotated methods with Lombok

64 views
Skip to first unread message

Mat Jaggard

unread,
Nov 16, 2011, 4:34:52 AM11/16/11
to Project Lombok
I am using Google Guice and need to annotate an entire constructor
with @Inject, but at the moment I can't find how to do it. I think I
remember reading this prevously but I can't remember now.

This is what I have at the moment...
@Singleton
@AllArgsConstructor
@Log
public class MyClass
{
@Inject
private Provider<UserService> usp;
@Inject
private Template template;
@Inject
private Provider<MyDAO> myDAOp;

...
}

But I'd like to @Inject on the constructor instead of the fields.
Something like this...


@Singleton
@AllArgsConstructor(withAnnotation=@Inject)
@Log
public class MyClass
{
private Provider<UserService> usp;
private Template template;
private Provider<MyDAO> myDAOp;

...
}

Reinier Zwitserloot

unread,
Nov 16, 2011, 6:07:03 AM11/16/11
to project...@googlegroups.com
You cannot currently do this. For a while there you could with an 0.10.0 beta, pretty much in the way you describe (except it's @AllArgsConstructor(onConstructor=@Inject)), but we removed that feature from 0.10.0 final because it wasn't compatible with javac7 at all.

We found a way to re-enable the feature for javac7 and we'll probably be adding it to 0.10.4.

Matthew Jaggard

unread,
Nov 16, 2011, 6:17:02 AM11/16/11
to project...@googlegroups.com
Thanks for the quick response and I look forward to that release :-)

On 16 November 2011 11:07, Reinier Zwitserloot <rein...@gmail.com> wrote:
You cannot currently do this. For a while there you could with an 0.10.0 beta, pretty much in the way you describe (except it's @AllArgsConstructor(onConstructor=@Inject)), but we removed that feature from 0.10.0 final because it wasn't compatible with javac7 at all.

We found a way to re-enable the feature for javac7 and we'll probably be adding it to 0.10.4.

--
You received this message because you are subscribed to the Google
Groups group for http://projectlombok.org/
 
To post to this group, send email to project...@googlegroups.com
To unsubscribe from this group, send email to
project-lombo...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/project-lombok?hl=en

Reply all
Reply to author
Forward
0 new messages