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

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

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

Key.getAnnotationType介绍

[英]Gets the annotation type.
[中]获取批注类型。

代码示例

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

protected void checkNotAnnotated() {
  if (key.getAnnotationType() != null) {
    binder.addError(AbstractBindingBuilder.ANNOTATION_ALREADY_SPECIFIED);
  }
}

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

protected void checkNotAnnotated() {
  if (binding.getKey().getAnnotationType() != null) {
    binder.addError(ANNOTATION_ALREADY_SPECIFIED);
  }
}

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

@Override
  public String toString(Key key) {
    if (key.getAnnotationType() != null) {
      return key.getTypeLiteral() + " annotated with "
          + (key.getAnnotation() != null ? key.getAnnotation() : key.getAnnotationType());
    } else {
      return key.getTypeLiteral().toString();
    }
  }
}

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

private void toConstant(Class<?> type, Object instance) {
  // this type will define T, so these assignments are safe
  @SuppressWarnings("unchecked")
  Class<T> typeAsClassT = (Class<T>) type;
  @SuppressWarnings("unchecked")
  T instanceAsT = (T) instance;
  if (keyTypeIsSet()) {
    binder.addError(CONSTANT_VALUE_ALREADY_SET);
    return;
  }
  BindingImpl<T> base = getBinding();
  Key<T> key;
  if (base.getKey().getAnnotation() != null) {
    key = Key.get(typeAsClassT, base.getKey().getAnnotation());
  } else if (base.getKey().getAnnotationType() != null) {
    key = Key.get(typeAsClassT, base.getKey().getAnnotationType());
  } else {
    key = Key.get(typeAsClassT);
  }
  if (instanceAsT == null) {
    binder.addError(BINDING_TO_NULL);
  }
  setBinding(new InstanceBindingImpl<>(
      base.getSource(), key, base.getScoping(), emptySet(), instanceAsT));
}

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

protected void checkNotAnnotated() {
  if (key.getAnnotationType() != null) {
    binder.addError(AbstractBindingBuilder.ANNOTATION_ALREADY_SPECIFIED);
  }
}

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

protected void checkNotAnnotated() {
  if (key.getAnnotationType() != null) {
    binder.addError(AbstractBindingBuilder.ANNOTATION_ALREADY_SPECIFIED);
  }
}

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

protected void checkNotAnnotated() {
  if (key.getAnnotationType() != null) {
    binder.addError(AbstractBindingBuilder.ANNOTATION_ALREADY_SPECIFIED);
  }
}

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

protected void checkNotAnnotated() {
  if (key.getAnnotationType() != null) {
    binder.addError(AbstractBindingBuilder.ANNOTATION_ALREADY_SPECIFIED);
  }
}

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

protected void checkNotAnnotated() {
  if (binding.getKey().getAnnotationType() != null) {
    binder.addError(ANNOTATION_ALREADY_SPECIFIED);
  }
}

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

protected void checkNotAnnotated() {
  if (binding.getKey().getAnnotationType() != null) {
    binder.addError(ANNOTATION_ALREADY_SPECIFIED);
  }
}

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

protected void checkNotAnnotated() {
  if (binding.getKey().getAnnotationType() != null) {
    binder.addError(ANNOTATION_ALREADY_SPECIFIED);
  }
}

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

/**
 * Returns a key similar to {@code key}, but with an {@literal @}Assisted binding annotation.
 * This fails if another binding annotation is clobbered in the process. If the key already has
 * the {@literal @}Assisted annotation, it is returned as-is to preserve any String value.
 */
private <T> Key<T> assistKey(Method method, Key<T> key, Errors errors) throws ErrorsException {
  if (key.getAnnotationType() == null) {
    return Key.get(key.getTypeLiteral(), DEFAULT_ANNOTATION);
  } else if (key.getAnnotationType() == Assisted.class) {
    return key;
  } else {
    errors.withSource(method).addMessage(
        "Only @Assisted is allowed for factory parameters, but found @%s",
        key.getAnnotationType());
    throw errors.toException();
  }
}

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

protected void checkNotAnnotated() {
  if (binding.getKey().getAnnotationType() != null) {
    binder.addError(ANNOTATION_ALREADY_SPECIFIED);
  }
}

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

@Override
  public String toString(Key key) {
    if (key.getAnnotationType() != null) {
      return key.getTypeLiteral() + " annotated with "
          + (key.getAnnotation() != null ? key.getAnnotation() : key.getAnnotationType());
    } else {
      return key.getTypeLiteral().toString();
    }
  }
}

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

@Override
  public String toString(Key key) {
    if (key.getAnnotationType() != null) {
      return key.getTypeLiteral() + " annotated with "
          + (key.getAnnotation() != null ? key.getAnnotation() : key.getAnnotationType());
    } else {
      return key.getTypeLiteral().toString();
    }
  }
}

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

@Override
  public String toString(Key key) {
    if (key.getAnnotationType() != null) {
      return key.getTypeLiteral() + " annotated with "
          + (key.getAnnotation() != null ? key.getAnnotation() : key.getAnnotationType());
    } else {
      return key.getTypeLiteral().toString();
    }
  }
}

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

@Override
  public String toString(Key key) {
    if (key.getAnnotationType() != null) {
      return key.getTypeLiteral() + " annotated with "
          + (key.getAnnotation() != null ? key.getAnnotation() : key.getAnnotationType());
    } else {
      return key.getTypeLiteral().toString();
    }
  }
}

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

private void toConstant(Class<?> type, Object instance) {
  // this type will define T, so these assignments are safe
  @SuppressWarnings("unchecked")
  Class<T> typeAsClassT = (Class<T>) type;
  @SuppressWarnings("unchecked")
  T instanceAsT = (T) instance;
  if (keyTypeIsSet()) {
    binder.addError(CONSTANT_VALUE_ALREADY_SET);
    return;
  }
  BindingImpl<T> base = getBinding();
  Key<T> key;
  if (base.getKey().getAnnotation() != null) {
    key = Key.get(typeAsClassT, base.getKey().getAnnotation());
  } else if (base.getKey().getAnnotationType() != null) {
    key = Key.get(typeAsClassT, base.getKey().getAnnotationType());
  } else {
    key = Key.get(typeAsClassT);
  }
  if (instanceAsT == null) {
    binder.addError(BINDING_TO_NULL);
  }
  setBinding(new InstanceBindingImpl<>(
      base.getSource(), key, base.getScoping(), emptySet(), instanceAsT));
}

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

private void toConstant(Class<?> type, Object instance) {
  // this type will define T, so these assignments are safe
  @SuppressWarnings("unchecked")
  Class<T> typeAsClassT = (Class<T>) type;
  @SuppressWarnings("unchecked")
  T instanceAsT = (T) instance;
  if (keyTypeIsSet()) {
    binder.addError(CONSTANT_VALUE_ALREADY_SET);
    return;
  }
  BindingImpl<T> base = getBinding();
  Key<T> key;
  if (base.getKey().getAnnotation() != null) {
    key = Key.get(typeAsClassT, base.getKey().getAnnotation());
  } else if (base.getKey().getAnnotationType() != null) {
    key = Key.get(typeAsClassT, base.getKey().getAnnotationType());
  } else {
    key = Key.get(typeAsClassT);
  }
  if (instanceAsT == null) {
    binder.addError(BINDING_TO_NULL);
  }
  setBinding(new InstanceBindingImpl<>(
      base.getSource(), key, base.getScoping(), emptySet(), instanceAsT));
}

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

private void toConstant(Class<?> type, Object instance) {
  // this type will define T, so these assignments are safe
  @SuppressWarnings("unchecked")
  Class<T> typeAsClassT = (Class<T>) type;
  @SuppressWarnings("unchecked")
  T instanceAsT = (T) instance;
  if (keyTypeIsSet()) {
    binder.addError(CONSTANT_VALUE_ALREADY_SET);
    return;
  }
  BindingImpl<T> base = getBinding();
  Key<T> key;
  if (base.getKey().getAnnotation() != null) {
    key = Key.get(typeAsClassT, base.getKey().getAnnotation());
  } else if (base.getKey().getAnnotationType() != null) {
    key = Key.get(typeAsClassT, base.getKey().getAnnotationType());
  } else {
    key = Key.get(typeAsClassT);
  }
  if (instanceAsT == null) {
    binder.addError(BINDING_TO_NULL);
  }
  setBinding(new InstanceBindingImpl<>(
      base.getSource(), key, base.getScoping(), emptySet(), instanceAsT));
}

相关文章