下面列出了com.google.inject.matcher.AbstractMatcher#com.google.inject.spi.TypeConverter 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
protected void configure() {
convertToTypes(new AbstractMatcher<TypeLiteral<?>>() {
@Override
public boolean matches(TypeLiteral<?> typeLiteral) {
return typeLiteral.getType().equals(Sample.class);
}
}, new TypeConverter() {
@Override
public Object convert(String value, TypeLiteral<?> toType) {
return new Sample();
}
});
bindConstant().annotatedWith(Names.named("smth")).to(12);
bindConstant().annotatedWith(Names.named("string")).to("12");
}