I envision your interface as:
interface ColumnFactory {
<K, V> Column<K, V> newColumn(
K name, V value, long timestampMillis);
}
Then you could adapt your current implementation:
bind(ColumnFactory.class)
.toProvider(new Provider<ColumnFactory>(){
@Override public ColumnFactory get() {
return new ColumnFactory() {
@Override public <K, V> Column<K, V>
newColumn(
K name, V value, long timestampMillis) {
return Builder.newColumn(
name, value, timestampMillis);
}
);
}
}});
Nothing to worry about here with generic methods.
-Fred
On Sat, Nov 20, 2010 at 8:58 AM, Bill de hÓra <[email protected]> wrote:
>
> I have a Builder object that generates objects with generic methods like
> this -
>
> public class Builder
> {
> public static <K, V> Column<K, V> newColumn(K name, V value, long
> tstamp) {
> return new ColumnImpl<K, V>(name, value, tstamp);
> }
> }
>
> ie, it's akin to Guava's Maps/Lists classes. I'd like the impl classes to
> be provided by Guice, eg
>
> public class Builder
> {
> private static Injector theInjector = Guice.createInjector(new
> datagrid.api.module.Module());
> private static ColumnFactory theColumnFactory =
> theInjector.getInstance(ColumnFactory.class);
>
> public static <K, V> Column<K, V> newColumn(K name, V value, long
> tstamp) {
> return theColumnFactory.create(name, value, long);
> }
> }
>
> Am I right in saying Guice doesn't supporting binding generic methods
> currently even with TypeLiteral/FactoryProvider tricks?
>
> Bill
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<google-guice%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>
--
You received this message because you are subscribed to the Google Groups
"google-guice" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-guice?hl=en.