本文整理了Java中com.google.inject.TypeLiteral.get()
方法的一些代码示例,展示了TypeLiteral.get()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TypeLiteral.get()
方法的具体详情如下:
包路径:com.google.inject.TypeLiteral
类名称:TypeLiteral
方法名:get
[英]Gets type literal for the given Class instance.
[中]获取给定类实例的类型文字。
代码示例来源:origin: com.google.inject/guice
@SuppressWarnings("unchecked") // a map of <K, V> is safely a Map<K, V>
static <K, V> TypeLiteral<Map<K, V>> mapOf(TypeLiteral<K> keyType, TypeLiteral<V> valueType) {
return (TypeLiteral<Map<K, V>>)
TypeLiteral.get(Types.mapOf(keyType.getType(), valueType.getType()));
}
代码示例来源:origin: com.google.inject/guice
/**
* Returns a new mapbinder that collects entries of {@code keyType}/{@code valueType} in a {@link
* Map} that is itself bound with {@code annotation}.
*/
public static <K, V> MapBinder<K, V> newMapBinder(
Binder binder, Class<K> keyType, Class<V> valueType, Annotation annotation) {
return newMapBinder(binder, TypeLiteral.get(keyType), TypeLiteral.get(valueType), annotation);
}
代码示例来源:origin: com.google.inject/guice
private ProviderMethodsModule(
Object delegate, boolean skipFastClassGeneration, ModuleAnnotatedMethodScanner scanner) {
this.delegate = checkNotNull(delegate, "delegate");
this.typeLiteral = TypeLiteral.get(this.delegate.getClass());
this.skipFastClassGeneration = skipFastClassGeneration;
this.scanner = scanner;
}
代码示例来源:origin: com.google.inject/guice
@SuppressWarnings("unchecked") // a provider entry <K, V> is safely a Map.Entry<K, Provider<V>>
static <K, V> TypeLiteral<Map.Entry<K, Provider<V>>> entryOfJavaxProviderOf(
TypeLiteral<K> keyType, TypeLiteral<V> valueType) {
return (TypeLiteral<Map.Entry<K, Provider<V>>>)
TypeLiteral.get(
newParameterizedTypeWithOwner(
Map.class,
Map.Entry.class,
keyType.getType(),
Types.javaxProviderOf(valueType.getType())));
}
代码示例来源:origin: com.google.inject/guice
/**
* Returns a new mapbinder that collects entries of {@code keyType}/{@code valueType} in a {@link
* Map} that is itself bound with {@code annotationType}.
*/
public static <K, V> MapBinder<K, V> newMapBinder(
Binder binder,
Class<K> keyType,
Class<V> valueType,
Class<? extends Annotation> annotationType) {
return newMapBinder(
binder, TypeLiteral.get(keyType), TypeLiteral.get(valueType), annotationType);
}
代码示例来源:origin: com.google.inject/guice
@SuppressWarnings("unchecked") // a provider map <K, Set<V>> is safely a Map<K, Set<Provider<V>>>
static <K, V>
TypeLiteral<Map<K, Collection<javax.inject.Provider<V>>>> mapOfCollectionOfJavaxProviderOf(
TypeLiteral<K> keyType, TypeLiteral<V> valueType) {
return (TypeLiteral<Map<K, Collection<javax.inject.Provider<V>>>>)
TypeLiteral.get(
Types.mapOf(
keyType.getType(), Types.collectionOf(Types.javaxProviderOf(valueType.getType()))));
}
代码示例来源:origin: apache/incubator-druid
public static MapBinder<Class<? extends Query>, QueryRunnerFactory> queryRunnerFactoryBinder(Binder binder)
{
return MapBinder.newMapBinder(
binder,
new TypeLiteral<Class<? extends Query>>(){},
TypeLiteral.get(QueryRunnerFactory.class)
);
}
代码示例来源:origin: com.google.inject/guice
static <T> TypeLiteral<?> javaOptionalOfJavaxProvider(TypeLiteral<T> type) {
checkState(JAVA_OPTIONAL_CLASS != null, "java.util.Optional not found");
return TypeLiteral.get(
Types.newParameterizedType(
JAVA_OPTIONAL_CLASS,
newParameterizedType(javax.inject.Provider.class, type.getType())));
}
代码示例来源:origin: Graylog2/graylog2-server
public static MapBinder<String, Function<?>> processorFunctionBinder(Binder binder) {
return MapBinder.newMapBinder(binder, TypeLiteral.get(String.class), new TypeLiteral<Function<?>>() {});
}
代码示例来源:origin: com.google.inject/guice
@SuppressWarnings("unchecked") // a provider map <K, Set<V>> is safely a Map<K, Set<Provider<V>>>
static <K, V> TypeLiteral<Map<K, Set<javax.inject.Provider<V>>>> mapOfSetOfJavaxProviderOf(
TypeLiteral<K> keyType, TypeLiteral<V> valueType) {
return (TypeLiteral<Map<K, Set<javax.inject.Provider<V>>>>)
TypeLiteral.get(
Types.mapOf(
keyType.getType(), Types.setOf(Types.javaxProviderOf(valueType.getType()))));
}
代码示例来源:origin: Graylog2/graylog2-server
private MapBinder<String, Function<?>> processorFunctionBinder(Binder binder) {
return MapBinder.newMapBinder(binder, TypeLiteral.get(String.class), new TypeLiteral<Function<?>>() {});
}
代码示例来源:origin: com.google.inject/guice
/**
* Returns a new injection point for the injectable constructor of {@code type}.
*
* @param type a concrete type with exactly one constructor annotated {@literal @}{@link Inject},
* or a no-arguments constructor that is not private.
* @throws ConfigurationException if there is no injectable constructor, more than one injectable
* constructor, or if parameters of the injectable constructor are malformed, such as a
* parameter with multiple binding annotations.
*/
public static InjectionPoint forConstructorOf(Class<?> type) {
return forConstructorOf(TypeLiteral.get(type));
}
代码示例来源:origin: com.google.inject/guice
@Override
@SuppressWarnings("unchecked") // it is safe to use the type literal for the raw type
public void requestInjection(Object instance) {
requestInjection((TypeLiteral<Object>) TypeLiteral.get(instance.getClass()), instance);
}
代码示例来源:origin: com.google.inject/guice
public void validate(Errors errors) throws ErrorsException {
@SuppressWarnings("unchecked") // the type of 'T' is a TypeLiteral<T>
TypeLiteral<T> type = TypeLiteral.get((Class<T>) instance.getClass());
membersInjector = injector.membersInjectorStore.get(type, errors.withSource(source));
Preconditions.checkNotNull(
membersInjector,
"No membersInjector available for instance: %s, from key: %s",
instance,
key);
state = InjectableReferenceState.VALIDATED;
}
代码示例来源:origin: Graylog2/graylog2-server
protected MapBinder<String, Codec.Factory<? extends Codec>> codecMapBinder() {
return MapBinder.newMapBinder(binder(),
TypeLiteral.get(String.class),
new TypeLiteral<Codec.Factory<? extends Codec>>() {
});
}
代码示例来源:origin: Graylog2/graylog2-server
protected MapBinder<String, Transport.Factory<? extends Transport>> transportMapBinder() {
return MapBinder.newMapBinder(binder(),
TypeLiteral.get(String.class),
new TypeLiteral<Transport.Factory<? extends Transport>>() {
});
}
代码示例来源:origin: Graylog2/graylog2-server
protected MapBinder<String, MessageOutput.Factory<? extends MessageOutput>> outputsMapBinder() {
return MapBinder.newMapBinder(binder(),
TypeLiteral.get(String.class),
new TypeLiteral<MessageOutput.Factory<? extends MessageOutput>>() {
});
}
代码示例来源:origin: Graylog2/graylog2-server
protected MapBinder<String, MessageInput.Factory<? extends MessageInput>> inputsMapBinder() {
return MapBinder.newMapBinder(binder(),
TypeLiteral.get(String.class),
new TypeLiteral<MessageInput.Factory<? extends MessageInput>>() {
});
}
代码示例来源:origin: Graylog2/graylog2-server
protected MapBinder<String, WidgetStrategy.Factory<? extends WidgetStrategy>> widgetStrategyBinder() {
return MapBinder.newMapBinder(binder(), TypeLiteral.get(String.class), new TypeLiteral<WidgetStrategy.Factory<? extends WidgetStrategy>>() {
});
}
代码示例来源:origin: com.google.inject/guice
/** Unsafe. Constructs a key from a manually specified type. */
@SuppressWarnings("unchecked")
private Key(Type type, AnnotationStrategy annotationStrategy) {
this.annotationStrategy = annotationStrategy;
this.typeLiteral = MoreTypes.canonicalizeForKey((TypeLiteral<T>) TypeLiteral.get(type));
this.hashCode = computeHashCode();
}
内容来源于网络,如有侵权,请联系作者删除!