frjaeger220 / google-guice

Automatically exported from code.google.com/p/google-guice
Apache License 2.0
0 stars 0 forks source link

requireBinding() should work with TypeLiteral #438

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I would like to require that there be a binding for a List of Strings before 
someone else can use my module.

requireBinding(new TypeLiteral<List<String>>() {});

Should work, but there is no support for such a call.

Work Around:
  requireBinding(Key.get(new TypeLiteral<List<String>>() {}));

Simple implementation:

public void requireBinding(TypeLiteral<T> typeLiteral) {
  requireBinding(Key.get(typeLiteral));
}

Original issue reported on code.google.com by elj...@gmail.com on 14 Oct 2009 at 10:50

GoogleCodeExporter commented 9 years ago
You could also do:

requireBinding(new Key<List<String>>() {});

Original comment by isaac.q....@gmail.com on 14 Oct 2009 at 11:02

GoogleCodeExporter commented 9 years ago
See Isaac's comment.

Original comment by sberlin on 20 Feb 2011 at 12:52