Hi Guice folks,
The project I am working on has a weird notation for configuration
properties that 1 stands for True and anything else for False.
Binder.convertToTypes() seems quite convenient for me to declare my own
String -> Boolean conversion. What I am not sure is this seems to coexist
with the internal primitive bindings for String -> Boolean. Therefore
although my conversion seems to effectively override the internal
conversion, I would like to check if it is indeed OK so that it is
reasonably less likely to break in the future releases of Guice. Thanks!
binder().convertToTypes(Matchers.only(TypeLiteral.get(Boolean.class)), new
TypeConverter() {
@Override
public Object convert(String value, TypeLiteral<?> toType) {
return Boolean.parseBoolean(value) || value.equals("1");
}
});
BTW, I would be doing this in private modules to be less pervasive.
Best,
-Kevin
--
You received this message because you are subscribed to the Google Groups
"google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-guice?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.