当前位置: 首页>>代码示例>>Java>>正文


Java MoreElements.getAnnotationMirror方法代码示例

本文整理汇总了Java中com.google.auto.common.MoreElements.getAnnotationMirror方法的典型用法代码示例。如果您正苦于以下问题:Java MoreElements.getAnnotationMirror方法的具体用法?Java MoreElements.getAnnotationMirror怎么用?Java MoreElements.getAnnotationMirror使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.auto.common.MoreElements的用法示例。


在下文中一共展示了MoreElements.getAnnotationMirror方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findOptionsMirror

import com.google.auto.common.MoreElements; //导入方法依赖的package包/类
private static Optional<AnnotationMirror> findOptionsMirror(TypeElement element) {
  Optional<AnnotationMirror> result =
      MoreElements.getAnnotationMirror(element, PaperParcel.Options.class);
  if (!result.isPresent()) {
    ImmutableSet<? extends AnnotationMirror> annotatedAnnotations =
        AnnotationMirrors.getAnnotatedAnnotations(element, PaperParcel.Options.class);
    if (annotatedAnnotations.size() > 1) {
      throw new IllegalStateException("PaperParcel options applied twice.");
    } else if (annotatedAnnotations.size() == 1) {
      AnnotationMirror annotatedAnnotation = annotatedAnnotations.iterator().next();
      result = MoreElements.getAnnotationMirror(
          annotatedAnnotation.getAnnotationType().asElement(), PaperParcel.Options.class);
    } else {
      TypeMirror superType = element.getSuperclass();
      if (superType.getKind() != TypeKind.NONE) {
        TypeElement superElement = asType(asDeclared(superType).asElement());
        result = findOptionsMirror(superElement);
      }
    }
  }
  return result;
}
 
开发者ID:grandstaish,项目名称:paperparcel,代码行数:23,代码来源:Utils.java

示例2: getParameterFrom

import com.google.auto.common.MoreElements; //导入方法依赖的package包/类
private static Optional<AnnotationValue> getParameterFrom(TypeElement typeElement
        , Class<? extends Annotation> annotationClass
        , String paramName
        , ProcessingEnvironment env) {
    Optional<AnnotationMirror> annotationMirror = MoreElements.getAnnotationMirror(typeElement, annotationClass);

    if (annotationMirror.isPresent()) {
        AnnotationValue value = getAnnotationValue(annotationMirror.get(), paramName, env);

        return Optional.fromNullable(value);
    }

    return Optional.absent();
}
 
开发者ID:trollsoftware,项目名称:jcomposition,代码行数:15,代码来源:AnnotationUtils.java

示例3: getAnnotationValue

import com.google.auto.common.MoreElements; //导入方法依赖的package包/类
/**
 * If the given {@code element} is annotated with an {@link Annotation} of class {@code clazz}
 * it's value for {@code key} will be returned. Otherwise it will return null.
 *
 * @throws IllegalArgumentException if no element is defined with the given key.
 */
public static Object getAnnotationValue(
        Element element, Class<? extends Annotation> clazz, String key) {
    Optional<AnnotationMirror> annotation = MoreElements.getAnnotationMirror(element, clazz);
    if (annotation.isPresent()) {
        return AnnotationMirrors.getAnnotationValue(annotation.get(), key).getValue();
    }
    return null;
}
 
开发者ID:gabrielittner,项目名称:auto-value-extension-util,代码行数:15,代码来源:ElementUtil.java

示例4: getValueFromAnnotation

import com.google.auto.common.MoreElements; //导入方法依赖的package包/类
public static <T> T getValueFromAnnotation(Element element, Class<? extends Annotation> annotation, String name) {
    Optional<AnnotationMirror> annotationMirror = MoreElements.getAnnotationMirror(element, annotation);
    if (!annotationMirror.isPresent()) {
        return null;
    }

    AnnotationValue annotationValue = getAnnotationValue(annotationMirror.get(), name);
    return annotationValue != null ? (T) annotationValue.getValue() : null;
}
 
开发者ID:lukaspili,项目名称:processor-workflow,代码行数:10,代码来源:ExtractorUtils.java

示例5: getFieldsToParcel

import com.google.auto.common.MoreElements; //导入方法依赖的package包/类
/** Returns all non-excluded fields on a {@link PaperParcel} annotated {@link TypeElement}. */
static ImmutableList<VariableElement> getFieldsToParcel(
    TypeElement element, OptionsDescriptor options) {
  Optional<AnnotationMirror> paperParcelMirror =
      MoreElements.getAnnotationMirror(element, PaperParcel.class);
  if (paperParcelMirror.isPresent()) {
    ImmutableList.Builder<VariableElement> fields = ImmutableList.builder();
    getFieldsToParcelImpl(element, options, fields, new HashSet<Name>());
    return fields.build();
  } else {
    throw new IllegalArgumentException("element must be annotated with @PaperParcel");
  }
}
 
开发者ID:grandstaish,项目名称:paperparcel,代码行数:14,代码来源:Utils.java


注:本文中的com.google.auto.common.MoreElements.getAnnotationMirror方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。