本文整理了Java中org.elasticsearch.common.inject.Key.get()
方法的一些代码示例,展示了Key.get()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Key.get()
方法的具体详情如下:
包路径:org.elasticsearch.common.inject.Key
类名称:Key
方法名:get
[英]Gets a key for an injection type.
[中]获取注入类型的键。
代码示例来源:origin: org.elasticsearch/elasticsearch
private Key<?> getBindingForType(Type type) {
return bindingAnnotation != null
? Key.get(type, bindingAnnotation)
: Key.get(type);
}
代码示例来源:origin: org.elasticsearch/elasticsearch
@Override
public void annotatedWith(Class<? extends Annotation> annotationType) {
Objects.requireNonNull(annotationType, "annotationType");
checkNotAnnotated();
key = Key.get(key.getTypeLiteral(), annotationType);
}
代码示例来源:origin: org.elasticsearch/elasticsearch
@Override
public void annotatedWith(Annotation annotation) {
Objects.requireNonNull(annotation, "annotation");
checkNotAnnotated();
key = Key.get(key.getTypeLiteral(), annotation);
}
代码示例来源:origin: org.elasticsearch/elasticsearch
@Override
public <T> Provider<T> getProvider(Class<T> type) {
return getProvider(Key.get(type));
}
代码示例来源:origin: org.elasticsearch/elasticsearch
/**
* Sets the binding to a copy with the specified annotation on the bound key
*/
protected BindingImpl<T> annotatedWithInternal(Class<? extends Annotation> annotationType) {
Objects.requireNonNull(annotationType, "annotationType");
checkNotAnnotated();
return setBinding(binding.withKey(
Key.get(this.binding.getKey().getTypeLiteral(), annotationType)));
}
代码示例来源:origin: org.elasticsearch/elasticsearch
@Override
public BindingBuilder<T> toProvider(Class<? extends Provider<? extends T>> providerType) {
return toProvider(Key.get(providerType));
}
代码示例来源:origin: org.elasticsearch/elasticsearch
/**
* Sets the binding to a copy with the specified annotation on the bound key
*/
protected BindingImpl<T> annotatedWithInternal(Annotation annotation) {
Objects.requireNonNull(annotation, "annotation");
checkNotAnnotated();
return setBinding(binding.withKey(
Key.get(this.binding.getKey().getTypeLiteral(), annotation)));
}
代码示例来源:origin: org.elasticsearch/elasticsearch
@Override
public <T> Provider<T> getProvider(Class<T> type) {
return getProvider(Key.get(type));
}
代码示例来源:origin: org.elasticsearch/elasticsearch
@Override
public BindingBuilder<T> to(TypeLiteral<? extends T> implementation) {
return to(Key.get(implementation));
}
代码示例来源:origin: org.elasticsearch/elasticsearch
/**
* Gets a key for the given type, member and annotations.
*/
public static Key<?> getKey(TypeLiteral<?> type, Member member, Annotation[] annotations,
Errors errors) throws ErrorsException {
int numErrorsBefore = errors.size();
Annotation found = findBindingAnnotation(errors, member, annotations);
errors.throwIfNewErrors(numErrorsBefore);
return found == null ? Key.get(type) : Key.get(type, found);
}
代码示例来源:origin: org.elasticsearch/elasticsearch
/**
* Creates a constant binding to {@code @Named(key)} for each entry in
* {@code properties}.
*/
public static void bindProperties(Binder binder, Map<String, String> properties) {
binder = binder.skipSources(Names.class);
for (Map.Entry<String, String> entry : properties.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
binder.bind(Key.get(String.class, new NamedImpl(key))).toInstance(value);
}
}
代码示例来源:origin: org.elasticsearch/elasticsearch
/**
* The Logger is a special case because it knows the injection point of the injected member. It's
* the only binding that does this.
*/
private static void bindLogger(InjectorImpl injector) {
Key<Logger> key = Key.get(Logger.class);
LoggerFactory loggerFactory = new LoggerFactory();
injector.state.putBinding(key,
new ProviderInstanceBindingImpl<>(injector, key,
SourceProvider.UNKNOWN_SOURCE, loggerFactory, Scoping.UNSCOPED,
loggerFactory, emptySet()));
}
代码示例来源:origin: org.elasticsearch/elasticsearch
/**
* The Injector is a special case because we allow both parent and child injectors to both have
* a binding for that key.
*/
private static void bindInjector(InjectorImpl injector) {
Key<Injector> key = Key.get(Injector.class);
InjectorFactory injectorFactory = new InjectorFactory(injector);
injector.state.putBinding(key,
new ProviderInstanceBindingImpl<>(injector, key, SourceProvider.UNKNOWN_SOURCE,
injectorFactory, Scoping.UNSCOPED, injectorFactory,
emptySet()));
}
代码示例来源:origin: org.elasticsearch/elasticsearch
/**
* 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,
TypeLiteral<K> keyType, TypeLiteral<V> valueType, Annotation annotation) {
binder = binder.skipSources(MapBinder.class, RealMapBinder.class);
return newMapBinder(binder, valueType,
Key.get(mapOf(keyType, valueType), annotation),
Key.get(mapOfProviderOf(keyType, valueType), annotation),
Multibinder.newSetBinder(binder, entryOfProviderOf(keyType, valueType), annotation));
}
代码示例来源:origin: org.elasticsearch/elasticsearch
/**
* Returns a new mapbinder that collects entries of {@code keyType}/{@code valueType} in a
* {@link Map} that is itself bound with no binding annotation.
*/
public static <K, V> MapBinder<K, V> newMapBinder(Binder binder,
TypeLiteral<K> keyType, TypeLiteral<V> valueType) {
binder = binder.skipSources(MapBinder.class, RealMapBinder.class);
return newMapBinder(binder, valueType,
Key.get(mapOf(keyType, valueType)),
Key.get(mapOfProviderOf(keyType, valueType)),
Multibinder.newSetBinder(binder, entryOfProviderOf(keyType, valueType)));
}
代码示例来源:origin: org.elasticsearch/elasticsearch
/**
* 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, TypeLiteral<K> keyType,
TypeLiteral<V> valueType, Class<? extends Annotation> annotationType) {
binder = binder.skipSources(MapBinder.class, RealMapBinder.class);
return newMapBinder(binder, valueType,
Key.get(mapOf(keyType, valueType), annotationType),
Key.get(mapOfProviderOf(keyType, valueType), annotationType),
Multibinder.newSetBinder(binder, entryOfProviderOf(keyType, valueType), annotationType));
}
代码示例来源:origin: org.elasticsearch/elasticsearch
/**
* Returns a new multibinder that collects instances of {@code type} in a {@link Set} that is
* itself bound with {@code annotationType}.
*/
public static <T> Multibinder<T> newSetBinder(Binder binder, TypeLiteral<T> type,
Class<? extends Annotation> annotationType) {
binder = binder.skipSources(RealMultibinder.class, Multibinder.class);
RealMultibinder<T> result = new RealMultibinder<>(binder, type, "@" + annotationType.getName(),
Key.get(Multibinder.<T>setOf(type), annotationType));
binder.install(result);
return result;
}
代码示例来源:origin: org.elasticsearch/elasticsearch
/**
* Returns a new multibinder that collects instances of {@code type} in a {@link Set} that is
* itself bound with no binding annotation.
*/
public static <T> Multibinder<T> newSetBinder(Binder binder, TypeLiteral<T> type) {
binder = binder.skipSources(RealMultibinder.class, Multibinder.class);
RealMultibinder<T> result = new RealMultibinder<>(binder, type, "",
Key.get(Multibinder.<T>setOf(type)));
binder.install(result);
return result;
}
代码示例来源:origin: org.elasticsearch/elasticsearch
@Override
public LinkedBindingBuilder<T> addBinding() {
checkConfiguration(!isInitialized(), "Multibinder was already initialized");
return binder.bind(Key.get(elementType, new RealElement(setName)));
}
代码示例来源:origin: org.elasticsearch/elasticsearch
/**
* Returns a new multibinder that collects instances of {@code type} in a {@link Set} that is
* itself bound with {@code annotation}.
*/
public static <T> Multibinder<T> newSetBinder(
Binder binder, TypeLiteral<T> type, Annotation annotation) {
binder = binder.skipSources(RealMultibinder.class, Multibinder.class);
RealMultibinder<T> result = new RealMultibinder<>(binder, type, annotation.toString(),
Key.get(Multibinder.<T>setOf(type), annotation));
binder.install(result);
return result;
}
内容来源于网络,如有侵权,请联系作者删除!