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

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

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

Key.getAnnotation介绍

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

代码示例

代码示例来源: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 boolean keyMatches(Key<?> key) {
  return key.getTypeLiteral().equals(elementType)
      && key.getAnnotation() instanceof Element
      && ((Element) key.getAnnotation()).setName().equals(setName);
}

代码示例来源: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: harbby/presto-connectors

/**
 * Replace annotation instances with annotation types, this is only
 * appropriate for testing if a key is bound and not for injecting.
 * <p>
 * See Guice bug 125,
 * http://code.google.com/p/google-guice/issues/detail?id=125
 */
public Key<?> fixAnnotations(Key<?> key) {
  return key.getAnnotation() == null
      ? key
      : Key.get(key.getTypeLiteral(), key.getAnnotation().annotationType());
}

代码示例来源: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: com.strapdata.elasticsearch/elasticsearch

private boolean keyMatches(Key<?> key) {
  return key.getTypeLiteral().equals(elementType)
      && key.getAnnotation() instanceof Element
      && ((Element) key.getAnnotation()).setName().equals(setName);
}

代码示例来源: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

private boolean keyMatches(Key<?> key) {
  return key.getTypeLiteral().equals(elementType)
      && key.getAnnotation() instanceof Element
      && ((Element) key.getAnnotation()).setName().equals(setName);
}

代码示例来源: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: apache/servicemix-bundles

private boolean keyMatches(Key<?> key) {
  return key.getTypeLiteral().equals(elementType)
      && key.getAnnotation() instanceof Element
      && ((Element) key.getAnnotation()).setName().equals(setName);
}

代码示例来源: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: harbby/presto-connectors

private boolean keyMatches(Key<?> key) {
  return key.getTypeLiteral().equals(elementType)
      && key.getAnnotation() instanceof Element
      && ((Element) key.getAnnotation()).setName().equals(setName);
}

代码示例来源: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));
}

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

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(), ImmutableSet.<InjectionPoint>of(), instanceAsT));
}

相关文章