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


Java MoreElements.getPackage方法代码示例

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


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

示例1: validateSingleUid

import com.google.auto.common.MoreElements; //导入方法依赖的package包/类
static void validateSingleUid(Element element, boolean uidFound,
                              String uidElemenetName, ProcessingEnvironment processingEnvironment) {
    TypeElement typeElement = MoreElements.asType(element);
    PackageElement packageElement = MoreElements.getPackage(element);
    for (Element enclosed : packageElement.getEnclosedElements()) {
        TypeElement enclosedType = MoreElements.asType(enclosed);
        if (uidFound && Utils.hasUIDAnnotation(enclosedType)
                && !enclosedType.getQualifiedName().toString().equals(typeElement.getQualifiedName().toString())) {
            processingEnvironment.getMessager().printMessage(Diagnostic.Kind.ERROR.ERROR,
                    "Cannot have two @UID annotated elements in one package: " +
                    uidElemenetName + " and " +
                    enclosedType.getQualifiedName().toString() + ".");
        }
        uidFound = uidFound || Utils.hasUIDAnnotation(enclosedType);
        if (uidFound && uidElemenetName == null) {
            uidElemenetName = enclosedType.getQualifiedName().toString();
        }
    }
    TypeElement type = Utils.getTypeFromPackage(packageElement);
    List<TypeElement> typeElements = Utils.getAnnotationMirrorValueArrayAsTypeElementList(Utils.getTypeAnnotation(type));
    for (TypeElement elt : typeElements) {
        if (Utils.hasTypeAnnotation(elt)) {
            validateSingleUid(elt, uidFound, uidElemenetName, processingEnvironment);
        }
    }
}
 
开发者ID:Jongla,项目名称:braque,代码行数:27,代码来源:TypeValidator.java

示例2: validateThatCurrentPropertyIsReachableFromTheBaseType

import com.google.auto.common.MoreElements; //导入方法依赖的package包/类
private void validateThatCurrentPropertyIsReachableFromTheBaseType(TypeElement restElement, TypeElement currentProperty, TypeElement baseType,
                                                                   Map<String, TypeTree> typeTrees,
                                                                   ProcessingEnvironment processingEnvironment) {
    List<TypeElement> superAndSub = Utils.getSuperAndSubTypes(typeTrees.get(baseType.getQualifiedName().toString()));
    for (TypeElement typeElement : superAndSub) {
        PackageElement packageElement = MoreElements.getPackage(typeElement);
        for (Element element : packageElement.getEnclosedElements()) {
            TypeElement asType = MoreElements.asType(element);
            if (asType.getQualifiedName().toString().equals(currentProperty.getQualifiedName().toString())) {
                return;
            }
        }
    }
    processingEnvironment.getMessager().printMessage(Diagnostic.Kind.ERROR, "Properties must be reachable from their base type. " +
            "In the API endpoint "+restElement+ " for the method "+mOp+", the property "
            +currentProperty.getQualifiedName().toString()+" is not reachable from the (possibly inferred) base type "+
            baseType.getQualifiedName().toString()+".  If you're pretty sure that the property you're using makes sense in "+
            "the API call, then verify that $.class separators are correctly placed.  Remember: "+
            "$.class should be used to end an inner object in an API definition.  If multiple objects end at the same place," +
            " all levels must be closed with a $.class.  Think of $.class like closing curly brackets.");
}
 
开发者ID:Jongla,项目名称:braque,代码行数:22,代码来源:AbstractRestHandler.java

示例3: getUID

import com.google.auto.common.MoreElements; //导入方法依赖的package包/类
static TypeElement getUID(TypeElement typeElement) {
    PackageElement pkg = MoreElements.getPackage(typeElement);
    TypeElement uidElement = getUIDFromPackage(pkg);
    if (uidElement == null) {
        TypeElement type = getTypeFromPackage(pkg);
        for (TypeElement inAnnotation : getAnnotationMirrorValueArrayAsTypeElementList(getTypeAnnotation(type))) {
            if (hasTypeAnnotation(inAnnotation)) {
                return getUID(inAnnotation);
            }
        }
        return null;
    } else {
        return uidElement;
    }
}
 
开发者ID:Jongla,项目名称:braque,代码行数:16,代码来源:Utils.java

示例4: getPropertyAttachment

import com.google.auto.common.MoreElements; //导入方法依赖的package包/类
static TypeElement getPropertyAttachment(TypeElement typeElement) {
    PackageElement packageElement = MoreElements.getPackage(typeElement);
    return getTypeFromPackage(packageElement);
}
 
开发者ID:Jongla,项目名称:braque,代码行数:5,代码来源:Utils.java


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