-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@ProvidedBy doesn't work with enums #295
Comments
From limpbizkit on April 26, 2009 14:46:04 (No comment was entered for this change.) Labels: Priority-Low |
From Maaartinus on March 04, 2011 16:20:51 This bug is over 2 years old, and AFAIK, the fix is a (less then) one-liner. There's a (possibly useless) test in InjectorImpl.createUninitializedBinding commented as "Don't try to inject arrays, or enums." - the probable reason for this is the wrong assumption that it makes no sense at all. The test only makes it fail a bit faster in case of something is wrong, and may IMHO be completely omitted. Could you please do it? Attachment: gist |
From rkapsi on September 25, 2011 12:01:48 Here's an use-case if you need one. I have an enum that defines the various runtime environments of my software and I use the system properties to define the environment at startup. I'm currently using Module but
public static Env environment() { public static class EnvProvider implements Provider<Env> { |
From Maaartinus on December 16, 2013 01:38:40 I'd propose something like public enum Env { but I can see that the Provider-based approach is much more general (and needs no new annotation). My use case is exactly the same. In a few days we can celebrate the 5th birthday of this bug. |
Yes, let's celebrate! And no, I don't mind talking to myself (as long it's not too often). My above proposal is actually a different syntax for
So it looks like both |
For I agree it makes sense for |
Fixed in 1285790. |
I see I was wrong as the argument of @ImplementedBy must be a class, so a different annotation would be needed.
Sounds good, except in simple cases when I want it to work without any configuration. But @ProvidedBy solves it (although a bit verbosely). |
From limpbizkit on December 29, 2008 15:22:36
Thierry reports that
@
ProvidedBy doesn't work with enums.@
ImplementedBy and enums doesn'tmake sense, but this should definitely work.
Original issue: http://code.google.com/p/google-guice/issues/detail?id=295
The text was updated successfully, but these errors were encountered: