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


Java MoreTypes.asTypeElement方法代码示例

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


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

示例1: getCompositionMergeConflictPolicy

import com.google.auto.common.MoreTypes; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public static IMergeConflictPolicy getCompositionMergeConflictPolicy(TypeElement element, ProcessingEnvironment env) {
    Optional<AnnotationValue> value = getParameterFrom(element, Composition.class, "onConflict", env);

    if (value.isPresent()) {
        TypeElement typeElement = MoreTypes.asTypeElement((Type) value.get().getValue());
        try {
            return (IMergeConflictPolicy) Class.forName(typeElement.getQualifiedName().toString()).newInstance();
        } catch (Exception ignore) { }
    }

    throw new IncompleteAnnotationException(Composition.class, "onConflict");
}
 
开发者ID:trollsoftware,项目名称:jcomposition,代码行数:14,代码来源:AnnotationUtils.java

示例2: hasInheritedInjectionAnnotation

import com.google.auto.common.MoreTypes; //导入方法依赖的package包/类
public static boolean hasInheritedInjectionAnnotation(TypeElement element) {
    if (hasUseInjectionAnnotation(element))
        return true;

    for (TypeMirror typeInterface : element.getInterfaces()) {
        TypeElement asElement = MoreTypes.asTypeElement(typeInterface);

        if (hasUseInjectionAnnotation(asElement))
            return true;
    }

    return false;
}
 
开发者ID:trollsoftware,项目名称:jcomposition,代码行数:14,代码来源:AnnotationUtils.java

示例3: getMethodsMap

import com.google.auto.common.MoreTypes; //导入方法依赖的package包/类
/**
 * Get list of executable elements and list of overriders
 * @param element element that contains executable elements
 * @param env annotation processing environment
 * @return map
 */
public static Map<IExecutableElementContainer, List<ITypeElementPairContainer>> getMethodsMap(TypeElement element, ProcessingEnvironment env) {
    HashMap<IExecutableElementContainer, List<ITypeElementPairContainer>> map = new HashMap<IExecutableElementContainer, List<ITypeElementPairContainer>>();

    Map<Visibility, ? extends List<ExecutableElement>> executableElements = getVisibleExecutableElements(element, env);
    for (TypeMirror mirror : element.getInterfaces()) {
        TypeElement typeInterfaceElement = MoreTypes.asTypeElement(mirror);
        TypeElement bindClassType = AnnotationUtils.getBindClassType(typeInterfaceElement, env);

        if (bindClassType == null)
            continue;

        boolean hasInjectAnnotation = AnnotationUtils.hasUseInjectionAnnotation(typeInterfaceElement);

        Map<Visibility, ? extends List<ExecutableElement>> executableElementBind = getVisibleExecutableElements(bindClassType, env);
        List<ExecutableElement> publicInterfaceElements = executableElements.get(Visibility.PUBLIC);

        processInterfaceElements(publicInterfaceElements,
                executableElementBind.get(Visibility.PUBLIC),
                element, typeInterfaceElement, bindClassType, map, hasInjectAnnotation, env);

        processBindElements(publicInterfaceElements,
                executableElementBind.get(Visibility.PUBLIC),
                element, typeInterfaceElement, bindClassType, map, hasInjectAnnotation, env);

        processBindElements(publicInterfaceElements,
                executableElementBind.get(Visibility.PROTECTED),
                element, typeInterfaceElement, bindClassType, map, hasInjectAnnotation, env);

    }

    return map;
}
 
开发者ID:trollsoftware,项目名称:jcomposition,代码行数:39,代码来源:TypeElementUtils.java

示例4: visitDeclared

import com.google.auto.common.MoreTypes; //导入方法依赖的package包/类
@Override public TypeMirror visitDeclared(DeclaredType type, Types types) {
  TypeElement element = MoreTypes.asTypeElement(type);
  List<? extends TypeMirror> args = type.getTypeArguments();
  TypeMirror[] strippedArgs = new TypeMirror[args.size()];
  for (int i = 0; i < args.size(); i++) {
    TypeMirror arg = args.get(i);
    strippedArgs[i] = arg.accept(this, types);
  }
  return types.getDeclaredType(element, strippedArgs);
}
 
开发者ID:grandstaish,项目名称:paperparcel,代码行数:11,代码来源:Utils.java

示例5: getBindClassType

import com.google.auto.common.MoreTypes; //导入方法依赖的package包/类
public static TypeElement getBindClassType(TypeElement element, ProcessingEnvironment env) {
    Optional<AnnotationValue> value = getParameterFrom(element
            , Bind.class
            , "value"
            , env);

    if (value.isPresent()) {
        TypeElement typeElement = MoreTypes.asTypeElement((Type) value.get().getValue());
        AnnotationMirror bindMirror = MoreElements.getAnnotationMirror(typeElement, Bind.class).orNull();

        if (!typeElement.getKind().isClass()) {
            env.getMessager().printMessage(Diagnostic.Kind.ERROR
                    , "Bind's annotation value must be class"
                    , element
                    , bindMirror
                    , value.get());

            return null;
        }

        /**
         * Bind annotation is not valid if Bind's class value isn't implements element interface
         */
        javax.lang.model.util.Types types = env.getTypeUtils();

        if (!types.isAssignable(types.getDeclaredType(typeElement), types.getDeclaredType(element))
                && !types.isAssignable(typeElement.getSuperclass(), element.asType())) {
            env.getMessager().printMessage(Diagnostic.Kind.ERROR
                    , "Bind's annotation value class must implement " + element.getSimpleName() + " interface"
                    , element
                    , bindMirror
                    , value.get());

            return null;
        }

        return typeElement;
    }

    return null;
}
 
开发者ID:trollsoftware,项目名称:jcomposition,代码行数:42,代码来源:AnnotationUtils.java

示例6: getAnnotationMirrorValueAsTypeElement

import com.google.auto.common.MoreTypes; //导入方法依赖的package包/类
static TypeElement getAnnotationMirrorValueAsTypeElement(AnnotationMirror annotationMirror, String methodName) {
    AnnotationValue value = getAnnotationValue(annotationMirror, methodName);
    return value == null ? null : MoreTypes.asTypeElement((TypeMirror) value.getValue());
}
 
开发者ID:Jongla,项目名称:braque,代码行数:5,代码来源:Utils.java

示例7: element

import com.google.auto.common.MoreTypes; //导入方法依赖的package包/类
public TypeElement element() {
    return MoreTypes.asTypeElement(type());
}
 
开发者ID:talshani,项目名称:flux4j,代码行数:4,代码来源:ComponentModel.java


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