本文整理汇总了Java中com.google.inject.spi.TypeConverter类的典型用法代码示例。如果您正苦于以下问题:Java TypeConverter类的具体用法?Java TypeConverter怎么用?Java TypeConverter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TypeConverter类属于com.google.inject.spi包,在下文中一共展示了TypeConverter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: convertToClasses
import com.google.inject.spi.TypeConverter; //导入依赖的package包/类
private static void convertToClasses(
InjectorImpl injector, final Matcher<? super Class<?>> typeMatcher, TypeConverter converter) {
internalConvertToTypes(
injector,
new AbstractMatcher<TypeLiteral<?>>() {
@Override
public boolean matches(TypeLiteral<?> typeLiteral) {
Type type = typeLiteral.getType();
if (!(type instanceof Class)) {
return false;
}
Class<?> clazz = (Class<?>) type;
return typeMatcher.matches(clazz);
}
@Override
public String toString() {
return typeMatcher.toString();
}
},
converter);
}
开发者ID:google,项目名称:guice,代码行数:23,代码来源:TypeConverterBindingProcessor.java
示例2: convertToClasses
import com.google.inject.spi.TypeConverter; //导入依赖的package包/类
private static void convertToClasses(InjectorImpl injector,
final Matcher<? super Class<?>> typeMatcher, TypeConverter converter) {
internalConvertToTypes(injector, new AbstractMatcher<TypeLiteral<?>>() {
public boolean matches(TypeLiteral<?> typeLiteral) {
Type type = typeLiteral.getType();
if (!(type instanceof Class)) {
return false;
}
Class<?> clazz = (Class<?>) type;
return typeMatcher.matches(clazz);
}
@Override public String toString() {
return typeMatcher.toString();
}
}, converter);
}
开发者ID:cgruber,项目名称:guice-old,代码行数:18,代码来源:TypeConverterBindingProcessor.java
示例3: testStringIsConvertedOnlyOnce
import com.google.inject.spi.TypeConverter; //导入依赖的package包/类
public void testStringIsConvertedOnlyOnce() {
final TypeConverter converter = new TypeConverter() {
boolean converted = false;
public Object convert(String value, TypeLiteral<?> toType) {
if (converted) {
throw new AssertionFailedError("converted multiple times!");
}
converted = true;
return new Date();
}
};
Injector injector = Guice.createInjector(new AbstractModule() {
@Override protected void configure() {
convertToTypes(Matchers.only(TypeLiteral.get(Date.class)), converter);
bindConstant().annotatedWith(NumericValue.class).to("unused");
}
});
Date first = injector.getInstance(Key.get(Date.class, NumericValue.class));
Date second = injector.getInstance(Key.get(Date.class, NumericValue.class));
assertSame(first, second);
}
开发者ID:cgruber,项目名称:guice-old,代码行数:24,代码来源:TypeConversionTest.java
示例4: convertToClasses
import com.google.inject.spi.TypeConverter; //导入依赖的package包/类
private void convertToClasses(final Matcher<? super Class<?>> typeMatcher,
TypeConverter converter) {
internalConvertToTypes(new AbstractMatcher<TypeLiteral<?>>() {
public boolean matches(TypeLiteral<?> typeLiteral) {
Type type = typeLiteral.getType();
if (!(type instanceof Class)) {
return false;
}
Class<?> clazz = (Class<?>) type;
return typeMatcher.matches(clazz);
}
@Override public String toString() {
return typeMatcher.toString();
}
}, converter);
}
开发者ID:utopiazh,项目名称:google-guice,代码行数:18,代码来源:TypeConverterBindingProcessor.java
示例5: testStringIsConvertedOnlyOnce
import com.google.inject.spi.TypeConverter; //导入依赖的package包/类
public void testStringIsConvertedOnlyOnce() {
final TypeConverter converter = new TypeConverter() {
boolean converted = false;
public Object convert(String value, TypeLiteral<?> toType) {
if (converted) {
throw new AssertionFailedError("converted multiple times!");
}
converted = true;
return new Date();
}
};
Injector injector = Guice.createInjector(new AbstractModule() {
protected void configure() {
convertToTypes(Matchers.only(TypeLiteral.get(Date.class)), converter);
bindConstant().annotatedWith(NumericValue.class).to("unused");
}
});
Date first = injector.getInstance(Key.get(Date.class, NumericValue.class));
Date second = injector.getInstance(Key.get(Date.class, NumericValue.class));
assertSame(first, second);
}
开发者ID:utopiazh,项目名称:google-guice,代码行数:24,代码来源:TypeConversionTest.java
示例6: testStringIsConvertedOnlyOnce
import com.google.inject.spi.TypeConverter; //导入依赖的package包/类
public void testStringIsConvertedOnlyOnce() {
final TypeConverter converter =
new TypeConverter() {
boolean converted = false;
@Override
public Object convert(String value, TypeLiteral<?> toType) {
if (converted) {
throw new AssertionFailedError("converted multiple times!");
}
converted = true;
return new Date();
}
};
Injector injector =
Guice.createInjector(
new AbstractModule() {
@Override
protected void configure() {
convertToTypes(Matchers.only(TypeLiteral.get(Date.class)), converter);
bindConstant().annotatedWith(NumericValue.class).to("unused");
}
});
Date first = injector.getInstance(Key.get(Date.class, NumericValue.class));
Date second = injector.getInstance(Key.get(Date.class, NumericValue.class));
assertSame(first, second);
}
开发者ID:google,项目名称:guice,代码行数:30,代码来源:TypeConversionTest.java
示例7: mockTypeConverter
import com.google.inject.spi.TypeConverter; //导入依赖的package包/类
TypeConverter mockTypeConverter(final Object result) {
return new TypeConverter() {
@Override
public Object convert(String value, TypeLiteral<?> toType) {
return result;
}
@Override
public String toString() {
return "CustomConverter";
}
};
}
开发者ID:google,项目名称:guice,代码行数:14,代码来源:TypeConversionTest.java
示例8: failingTypeConverter
import com.google.inject.spi.TypeConverter; //导入依赖的package包/类
private static TypeConverter failingTypeConverter() {
return new TypeConverter() {
@Override
public Object convert(String value, TypeLiteral<?> toType) {
throw new UnsupportedOperationException("Cannot convert");
}
@Override
public String toString() {
return "BrokenConverter";
}
};
}
开发者ID:google,项目名称:guice,代码行数:14,代码来源:TypeConversionTest.java
示例9: mockTypeConverter
import com.google.inject.spi.TypeConverter; //导入依赖的package包/类
TypeConverter mockTypeConverter(final Object result) {
return new TypeConverter() {
public Object convert(String value, TypeLiteral<?> toType) {
return result;
}
@Override public String toString() {
return "CustomConverter";
}
};
}
开发者ID:cgruber,项目名称:guice-old,代码行数:12,代码来源:TypeConversionTest.java
示例10: failingTypeConverter
import com.google.inject.spi.TypeConverter; //导入依赖的package包/类
private static TypeConverter failingTypeConverter() {
return new TypeConverter() {
public Object convert(String value, TypeLiteral<?> toType) {
throw new UnsupportedOperationException("Cannot convert");
}
@Override public String toString() {
return "BrokenConverter";
}
};
}
开发者ID:cgruber,项目名称:guice-old,代码行数:11,代码来源:TypeConversionTest.java
示例11: failingTypeConverter
import com.google.inject.spi.TypeConverter; //导入依赖的package包/类
private TypeConverter failingTypeConverter() {
return new TypeConverter() {
public Object convert(String value, TypeLiteral<?> toType) {
throw new UnsupportedOperationException("Cannot convert");
}
@Override public String toString() {
return "BrokenConverter";
}
};
}
开发者ID:utopiazh,项目名称:google-guice,代码行数:11,代码来源:TypeConversionTest.java
示例12: convertToTypes
import com.google.inject.spi.TypeConverter; //导入依赖的package包/类
@Override
default void convertToTypes(final Matcher<? super TypeLiteral<?>> typeMatcher, final TypeConverter converter) {
this.binder().convertToTypes(typeMatcher, converter);
}
开发者ID:KyoriPowered,项目名称:violet,代码行数:5,代码来源:ForwardingBinder.java
示例13: convertToTypes
import com.google.inject.spi.TypeConverter; //导入依赖的package包/类
/**
* @see Binder#convertToTypes(com.google.inject.matcher.Matcher,
* com.google.inject.spi.TypeConverter)
*/
protected final void convertToTypes(
Matcher<? super TypeLiteral<?>> typeMatcher, TypeConverter converter) {
binder().convertToTypes(typeMatcher, converter);
}
开发者ID:google,项目名称:guice,代码行数:9,代码来源:PrivateModule.java
示例14: convertToClass
import com.google.inject.spi.TypeConverter; //导入依赖的package包/类
private static <T> void convertToClass(
InjectorImpl injector, Class<T> type, TypeConverter converter) {
convertToClasses(injector, Matchers.identicalTo(type), converter);
}
开发者ID:google,项目名称:guice,代码行数:5,代码来源:TypeConverterBindingProcessor.java
示例15: internalConvertToTypes
import com.google.inject.spi.TypeConverter; //导入依赖的package包/类
private static void internalConvertToTypes(
InjectorImpl injector, Matcher<? super TypeLiteral<?>> typeMatcher, TypeConverter converter) {
injector.state.addConverter(
new TypeConverterBinding(SourceProvider.UNKNOWN_SOURCE, typeMatcher, converter));
}
开发者ID:google,项目名称:guice,代码行数:6,代码来源:TypeConverterBindingProcessor.java
示例16: convertToTypes
import com.google.inject.spi.TypeConverter; //导入依赖的package包/类
/**
* @see Binder#convertToTypes
* @since 2.0
*/
protected void convertToTypes(
Matcher<? super TypeLiteral<?>> typeMatcher, TypeConverter converter) {
binder().convertToTypes(typeMatcher, converter);
}
开发者ID:google,项目名称:guice,代码行数:9,代码来源:AbstractModule.java
示例17: convertToTypes
import com.google.inject.spi.TypeConverter; //导入依赖的package包/类
/**
* @see Binder#convertToTypes(com.google.inject.matcher.Matcher, com.google.inject.spi.TypeConverter)
*/
protected final void convertToTypes(Matcher<? super TypeLiteral<?>> typeMatcher,
TypeConverter converter) {
binder().convertToTypes(typeMatcher, converter);
}
开发者ID:cgruber,项目名称:guice-old,代码行数:8,代码来源:PrivateModule.java
示例18: convertToClass
import com.google.inject.spi.TypeConverter; //导入依赖的package包/类
private static <T> void convertToClass(InjectorImpl injector, Class<T> type,
TypeConverter converter) {
convertToClasses(injector, Matchers.identicalTo(type), converter);
}
开发者ID:cgruber,项目名称:guice-old,代码行数:5,代码来源:TypeConverterBindingProcessor.java
示例19: internalConvertToTypes
import com.google.inject.spi.TypeConverter; //导入依赖的package包/类
private static void internalConvertToTypes(InjectorImpl injector,
Matcher<? super TypeLiteral<?>> typeMatcher,
TypeConverter converter) {
injector.state.addConverter(
new TypeConverterBinding(SourceProvider.UNKNOWN_SOURCE, typeMatcher, converter));
}
开发者ID:cgruber,项目名称:guice-old,代码行数:7,代码来源:TypeConverterBindingProcessor.java
示例20: convertToTypes
import com.google.inject.spi.TypeConverter; //导入依赖的package包/类
/**
* @see Binder#convertToTypes
* @since 2.0
*/
protected void convertToTypes(Matcher<? super TypeLiteral<?>> typeMatcher,
TypeConverter converter) {
binder().convertToTypes(typeMatcher, converter);
}
开发者ID:cgruber,项目名称:guice-old,代码行数:9,代码来源:AbstractModule.java
注:本文中的com.google.inject.spi.TypeConverter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论