org.elasticsearch.common.inject.Key.ofType()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(6.7k)|赞(0)|评价(0)|浏览(179)

本文整理了Java中org.elasticsearch.common.inject.Key.ofType()方法的一些代码示例,展示了Key.ofType()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Key.ofType()方法的具体详情如下:
包路径:org.elasticsearch.common.inject.Key
类名称:Key
方法名:ofType

Key.ofType介绍

[英]Returns a new key of the specified type with the same annotation as this key.
[中]返回具有与此键相同注释的指定类型的新键。

代码示例

代码示例来源:origin: org.elasticsearch/elasticsearch

/**
 * Gets the key of this key's provider.
 */
Key<Provider<T>> providerKey() {
  return ofType(typeLiteral.providerType());
}

代码示例来源:origin: org.elasticsearch/elasticsearch

/**
 * Creates a synthetic binding to {@code Provider<T>}, i.e. a binding to the provider from
 * {@code Binding<T>}.
 */
private <T> BindingImpl<Provider<T>> createProviderBinding(Key<Provider<T>> key, Errors errors)
    throws ErrorsException {
  Type providerType = key.getTypeLiteral().getType();
  // If the Provider has no type parameter (raw Provider)...
  if (!(providerType instanceof ParameterizedType)) {
    throw errors.cannotInjectRawProvider().toException();
  }
  Type entryType = ((ParameterizedType) providerType).getActualTypeArguments()[0];
  @SuppressWarnings("unchecked") // safe because T came from Key<Provider<T>>
      Key<T> providedKey = (Key<T>) key.ofType(entryType);
  BindingImpl<T> delegate = getBindingOrThrow(providedKey, errors);
  return new ProviderBindingImpl<>(this, key, delegate);
}

代码示例来源:origin: org.elasticsearch/elasticsearch

throws ErrorsException {
Key<String> stringKey = key.ofType(String.class);
BindingImpl<String> stringBinding = state.getExplicitBinding(stringKey);
if (stringBinding == null || !stringBinding.isConstant()) {

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch

/**
 * Gets the key of this key's provider.
 */
Key<Provider<T>> providerKey() {
  return ofType(typeLiteral.providerType());
}

代码示例来源:origin: harbby/presto-connectors

/**
 * Gets the key of this key's provider.
 */
Key<Provider<T>> providerKey() {
  return ofType(typeLiteral.providerType());
}

代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch

/**
 * Gets the key of this key's provider.
 */
Key<Provider<T>> providerKey() {
  return ofType(typeLiteral.providerType());
}

代码示例来源:origin: apache/servicemix-bundles

/**
 * Gets the key of this key's provider.
 */
Key<Provider<T>> providerKey() {
  return ofType(typeLiteral.providerType());
}

代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch

/**
 * Creates a synthetic binding to {@code Provider<T>}, i.e. a binding to the provider from
 * {@code Binding<T>}.
 */
private <T> BindingImpl<Provider<T>> createProviderBinding(Key<Provider<T>> key, Errors errors)
    throws ErrorsException {
  Type providerType = key.getTypeLiteral().getType();
  // If the Provider has no type parameter (raw Provider)...
  if (!(providerType instanceof ParameterizedType)) {
    throw errors.cannotInjectRawProvider().toException();
  }
  Type entryType = ((ParameterizedType) providerType).getActualTypeArguments()[0];
  @SuppressWarnings("unchecked") // safe because T came from Key<Provider<T>>
      Key<T> providedKey = (Key<T>) key.ofType(entryType);
  BindingImpl<T> delegate = getBindingOrThrow(providedKey, errors);
  return new ProviderBindingImpl<>(this, key, delegate);
}

代码示例来源:origin: apache/servicemix-bundles

/**
 * Creates a synthetic binding to {@code Provider<T>}, i.e. a binding to the provider from
 * {@code Binding<T>}.
 */
private <T> BindingImpl<Provider<T>> createProviderBinding(Key<Provider<T>> key, Errors errors)
    throws ErrorsException {
  Type providerType = key.getTypeLiteral().getType();
  // If the Provider has no type parameter (raw Provider)...
  if (!(providerType instanceof ParameterizedType)) {
    throw errors.cannotInjectRawProvider().toException();
  }
  Type entryType = ((ParameterizedType) providerType).getActualTypeArguments()[0];
  @SuppressWarnings("unchecked") // safe because T came from Key<Provider<T>>
      Key<T> providedKey = (Key<T>) key.ofType(entryType);
  BindingImpl<T> delegate = getBindingOrThrow(providedKey, errors);
  return new ProviderBindingImpl<>(this, key, delegate);
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch

/**
 * Creates a synthetic binding to {@code Provider<T>}, i.e. a binding to the provider from
 * {@code Binding<T>}.
 */
private <T> BindingImpl<Provider<T>> createProviderBinding(Key<Provider<T>> key, Errors errors)
    throws ErrorsException {
  Type providerType = key.getTypeLiteral().getType();
  // If the Provider has no type parameter (raw Provider)...
  if (!(providerType instanceof ParameterizedType)) {
    throw errors.cannotInjectRawProvider().toException();
  }
  Type entryType = ((ParameterizedType) providerType).getActualTypeArguments()[0];
  @SuppressWarnings("unchecked") // safe because T came from Key<Provider<T>>
      Key<T> providedKey = (Key<T>) key.ofType(entryType);
  BindingImpl<T> delegate = getBindingOrThrow(providedKey, errors);
  return new ProviderBindingImpl<>(this, key, delegate);
}

代码示例来源:origin: harbby/presto-connectors

/**
 * Creates a synthetic binding to {@code Provider<T>}, i.e. a binding to the provider from
 * {@code Binding<T>}.
 */
private <T> BindingImpl<Provider<T>> createProviderBinding(Key<Provider<T>> key, Errors errors)
    throws ErrorsException {
  Type providerType = key.getTypeLiteral().getType();
  // If the Provider has no type parameter (raw Provider)...
  if (!(providerType instanceof ParameterizedType)) {
    throw errors.cannotInjectRawProvider().toException();
  }
  Type entryType = ((ParameterizedType) providerType).getActualTypeArguments()[0];
  @SuppressWarnings("unchecked") // safe because T came from Key<Provider<T>>
      Key<T> providedKey = (Key<T>) key.ofType(entryType);
  BindingImpl<T> delegate = getBindingOrThrow(providedKey, errors);
  return new ProviderBindingImpl<>(this, key, delegate);
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch

throws ErrorsException {
Key<String> stringKey = key.ofType(String.class);
BindingImpl<String> stringBinding = state.getExplicitBinding(stringKey);
if (stringBinding == null || !stringBinding.isConstant()) {

代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch

throws ErrorsException {
Key<String> stringKey = key.ofType(String.class);
BindingImpl<String> stringBinding = state.getExplicitBinding(stringKey);
if (stringBinding == null || !stringBinding.isConstant()) {

代码示例来源:origin: apache/servicemix-bundles

throws ErrorsException {
Key<String> stringKey = key.ofType(String.class);
BindingImpl<String> stringBinding = state.getExplicitBinding(stringKey);
if (stringBinding == null || !stringBinding.isConstant()) {

代码示例来源:origin: harbby/presto-connectors

throws ErrorsException {
Key<String> stringKey = key.ofType(String.class);
BindingImpl<String> stringBinding = state.getExplicitBinding(stringKey);
if (stringBinding == null || !stringBinding.isConstant()) {

相关文章