Open GoogleCodeExporter opened 9 years ago
Yeah, only strings can be converted to constants. But I'll fix this...
Original comment by limpbizkit
on 25 Dec 2008 at 4:33
Original comment by limpbizkit
on 25 Dec 2008 at 4:42
If only Strings undergo conversion, is it correct for the EDSL doc in
Binder.java to state:
bindConstant().annotatedWith(ServerHost.class).to(args[0]);
Sets up a constant binding. Constant bindings are typeless in Guice; you
can provide the values in a variety of types and the values can be injected
in a variety of types; Guice performs the standard type conversions for you
behind the scenes.
Anecdotally, binding an Integer w/ a @Named and trying to @Inject it as a Float
did not seem to be successful.
Original comment by phopkins
on 26 Dec 2008 at 3:48
Code fixed with r743. I fixed the Javadoc with r744:
* <pre>
* bindConstant().annotatedWith(ServerHost.class).to(args[0]);</pre>
*
* Sets up a constant binding. Constant injections must always be annotated.
* When a constant binding's value is a string, it is eligile for conversion to
* all primitive types, to {@link Enum#valueOf(Class, String) all enums}, and to
* {@link Class#forName class literals}. Conversions for other types can be
* configured using {@link #convertToTypes(Matcher, TypeConverter)
* convertToTypes()}.
Original comment by limpbizkit
on 28 Dec 2008 at 12:09
Original issue reported on code.google.com by
phopkins
on 24 Dec 2008 at 6:26