本文整理汇总了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);
}
}
}
示例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.");
}
示例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;
}
}
示例4: getPropertyAttachment
import com.google.auto.common.MoreElements; //导入方法依赖的package包/类
static TypeElement getPropertyAttachment(TypeElement typeElement) {
PackageElement packageElement = MoreElements.getPackage(typeElement);
return getTypeFromPackage(packageElement);
}