Domanda

What im trying to do is to create map, where key will be class which extends my abstract class

GinMapBinder<Class<? extends Key>, Value> mapBinder = GinMapBinder
                .newMapBinder(binder(),
                        new TypeLiteral<Class<? extends Key>>() {
                        }, new TypeLiteral<Value>() {
                        });

but when i'm trying populate my map

mapBinder.addBinding(KeyImpl.class).to(Value.class);

i'm getting error:

 Error injecting @com.google.gwt.inject.client.multibindings.Internal() java.lang.Class<? extends my.test.gwt.gin.objects.Key>: Unable to create or inherit binding: No implementation bound   for '@com.google.gwt.inject.client.multibindings.Internal() java.lang.Class<? extendsmy.test.gwt.gin.objects.Key>' and an implicit binding cannot be created because the type is annotated.
  Path to required node:

 @com.google.gwt.inject.client.multibindings.Internal com.google.gwt.inject.client.multibindings.MapEntry<java.lang.Class<? extends my.test.gwt.gin.objects.Key>, my.test.gwt.gin.objects.Value> [com.google.gwt.inject.client.multibindings.BindingRecorder.bind(BindingRecorder.java:42)]
  -> com.google.gwt.inject.client.multibindings.MapEntry<java.lang.Class<? extends my.test.gwt.gin.objects.Key>, my.test.gwt.gin.objects.Value> [com.google.gwt.inject.client.multibindings.BindingRecorder.bind(BindingRecorder.java:42)]
  -> @com.google.gwt.inject.client.multibindings.Internal() java.lang.Class<? extends my.test.gwt.gin.objects.Key> [@Inject constructor of com.google.gwt.inject.client.multibindings.MapEntry<java.lang.Class<? extends my.test.gwt.gin.objects.Key>, my.test.gwt.gin.objects.Value>]

if i wont use TypeLiteralthis will works, but i dont want class with raw type. So i'll be glad if anyone can help me to solve this issue. Thanks in advance

È stato utile?

Soluzione

Problem Solved

I created provider for each Key

public class KeyImplProvider implements
        Provider<Class<KeyImpl>> {

    @Override
    public Class<KeyImpl> get() {
        return KeyImpl.class;
    }
}

and i'm adding elements to map by

mapBinder.addBinding(KeyImplProvider.class).to(Value.class);
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top