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


Java AnnotationValue.getValue方法代码示例

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


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

示例1: getProviderInterface

import javax.lang.model.element.AnnotationValue; //导入方法依赖的package包/类
private DeclaredType getProviderInterface(AnnotationMirror providerAnnotation) {

        // The very simplest of way of doing this, is also unfortunately unworkable.
        // We'd like to do:
        //    ServiceProvider provider = e.getAnnotation(ServiceProvider.class);
        //    Class<?> providerInterface = provider.value();
        //
        // but unfortunately we can't load the arbitrary class at annotation
        // processing time. So, instead, we have to use the mirror to get at the
        // value (much more painful).

        Map<? extends ExecutableElement, ? extends AnnotationValue> valueIndex =
                providerAnnotation.getElementValues();
        AnnotationValue value = valueIndex.values().iterator().next();
        return (DeclaredType) value.getValue();
    }
 
开发者ID:zillachan,项目名称:AndZilla,代码行数:17,代码来源:LifecycleProcessor.java

示例2: getClassAttributeFromAnnotationAsTypeMirror

import javax.lang.model.element.AnnotationValue; //导入方法依赖的package包/类
public static TypeMirror getClassAttributeFromAnnotationAsTypeMirror(Element element, Class<? extends Annotation> annotationType, String attributeName) {

        AnnotationMirror annotationMirror = getAnnotationMirror(element, annotationType);
        if (annotationMirror == null) {
            return null;
        }
        AnnotationValue annotationAttributeValue = getAnnotationValueOfAttribute(annotationMirror, attributeName);
        if (annotationAttributeValue == null) {
            return null;
        } else {
            return (TypeMirror) annotationAttributeValue.getValue();
        }

    }
 
开发者ID:toolisticon,项目名称:annotation-processor-toolkit,代码行数:15,代码来源:AnnotationUtils.java

示例3: convertOutputType

import javax.lang.model.element.AnnotationValue; //导入方法依赖的package包/类
OutputType convertOutputType(AnnotationValue outputTypeValue) {
    return (outputTypeValue != null
            && outputTypeValue.getValue() != null
            && Arrays.stream(OutputType.values()).anyMatch(x -> x.name().equals(outputTypeValue.getValue().toString())))
            ? OutputType.valueOf(outputTypeValue.getValue().toString())
            :null;

}
 
开发者ID:dzuvic,项目名称:jtsgen,代码行数:9,代码来源:TSModuleHandler.java

示例4: checkMembers

import javax.lang.model.element.AnnotationValue; //导入方法依赖的package包/类
protected boolean checkMembers(List<AnnotationValue> arrayMembers) {
    for (AnnotationValue arrayMember : arrayMembers) {
        Object value = arrayMember.getValue();
        if (!(value instanceof TypeMirror)) {
            return false;
        }
        TypeMirror type = (TypeMirror)value;
        if (!TypeKind.DECLARED.equals(type.getKind())) {
            return false;
        }
    }
    return true;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:AnnotationParser.java

示例5: getAnnotationValueClassName

import javax.lang.model.element.AnnotationValue; //导入方法依赖的package包/类
/**
 * Returns fully qualified class name of a class given to an annotation
 * as (the only) argument.
 * 
 * @param  annValue  annotation value
 * @return  fully qualified name of a class represented by the given
 *          annotation value, or {@code null} if the annotation value
 *          does not represent a class
 */
private Name getAnnotationValueClassName(AnnotationValue annValue,
                                         Types types) {
    Object value = annValue.getValue();
    if (value instanceof TypeMirror) {
        TypeMirror typeMirror = (TypeMirror) value;
        Element typeElement = types.asElement(typeMirror);
        if (typeElement.getKind() == ElementKind.CLASS) {
            return ((TypeElement) typeElement).getQualifiedName();
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:JUnit4TestGenerator.java

示例6: getGroupClassType

import javax.lang.model.element.AnnotationValue; //导入方法依赖的package包/类
public void getGroupClassType(TypeElement type, DUnitGroup dUnitGroup) {
		if (dUnitGroup != null) {
			mErrorReporter.reportWaring("asType:" + type.asType() + "     |getNestingKind:" + type.getNestingKind() + "     |getAnnotation:" + type.getAnnotation(DUnitGroup.class) + "    |getAnnotationMirrors:" + type.getAnnotationMirrors());
			mErrorReporter.reportWaring("------------>" + getRealClassName(type));
			List<? extends AnnotationMirror> mirrors = type.getAnnotationMirrors();
			if (mirrors.isEmpty()){
				return;
			}
			AnnotationMirror mirror = mirrors.get(0);
			mErrorReporter.reportWaring("----->mirror:" + mirror);
			Map<? extends ExecutableElement, ? extends AnnotationValue> map = mirror.getElementValues();
			Set<? extends Map.Entry<? extends ExecutableElement, ? extends AnnotationValue>> entries = map.entrySet();
			for (Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> entry :
					entries) {
				ExecutableElement executableElement = entry.getKey();
				mErrorReporter.reportWaring("executableElement" + executableElement);
				AnnotationValue annotationValue = entry.getValue();
				Object object = annotationValue.getValue();
//				boolean isClassType = object instanceof Type.ClassType;
//				if (isClassType) {
//					Type.ClassType classType = (Type.ClassType) object;
//					mErrorReporter.reportWaring(classType.toString() + "  |  " + classType.getOriginalType() + "  |  " + classType.getKind() + "  |  " + classType.getReturnType() + "   |  " + classType.getUpperBound());
//				}
			}

		}
	}
 
开发者ID:tik5213,项目名称:DUnit,代码行数:28,代码来源:DUnitModelUtil.java

示例7: getValue

import javax.lang.model.element.AnnotationValue; //导入方法依赖的package包/类
public Object getValue(AnnotationValue elementValue) {
    Object value = elementValue.getValue();
    if (value instanceof TypeMirror) {
        TypeMirror type = (TypeMirror)value;
        if (TypeKind.DECLARED.equals(type.getKind())) {
            return ((TypeElement)(((DeclaredType)value).asElement())).getQualifiedName().toString();
        }
    }
    return getDefaultValue();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:AnnotationParser.java

示例8: getClassMetaDataFromModule

import javax.lang.model.element.AnnotationValue; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private Set<String> getClassMetaDataFromModule(Element classElement) {
    AnnotationMirror annotationMirror = getAnnotationMirror(classElement);
    AnnotationValue annotationValue = getAnnotationValue(annotationMirror);
    Set<String> classes = new HashSet<String>();
    List<? extends AnnotationValue> moduleClasses = (List<? extends AnnotationValue>) annotationValue.getValue();
    for (AnnotationValue classMirror : moduleClasses) {
        String fullyQualifiedClassName = classMirror.getValue().toString();
        classes.add(fullyQualifiedClassName);
    }
    return classes;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:ModuleMetaData.java

示例9: warnUndocumented

import javax.lang.model.element.AnnotationValue; //导入方法依赖的package包/类
private void warnUndocumented(int i, Element e, String key) {
    AnnotationMirror mirror = null;
    AnnotationValue value = null;
    if (e != null) {
        for (AnnotationMirror _mirror : e.getAnnotationMirrors()) {
            if (_mirror.getAnnotationType().toString().equals(NbBundle.Messages.class.getCanonicalName())) {
                mirror = _mirror;
                for (Map.Entry<? extends ExecutableElement,? extends AnnotationValue> entry : mirror.getElementValues().entrySet()) {
                    if (entry.getKey().getSimpleName().contentEquals("value")) {
                        // SimpleAnnotationValueVisitor6 unusable here since we need to determine the AnnotationValue in scope when visitString is called:
                        Object v = entry.getValue().getValue();
                        if (v instanceof String) {
                            if (((String) v).startsWith(key + "=")) {
                                value = entry.getValue();
                            }
                        } else {
                            for (AnnotationValue subentry : NbCollections.checkedListByCopy((List<?>) v, AnnotationValue.class, true)) {
                                v = subentry.getValue();
                                if (v instanceof String) {
                                    if (((String) v).startsWith(key + "=")) {
                                        value = subentry;
                                        break;
                                    }
                                }
                            }
                        }
                        break;
                    }
                }
                break;
            }
        }
    }
    processingEnv.getMessager().printMessage(Kind.WARNING, "Undocumented format parameter {" + i + "}", e, mirror, value);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:36,代码来源:NbBundleProcessor.java

示例10: checkSuiteMembersAnnotation

import javax.lang.model.element.AnnotationValue; //导入方法依赖的package包/类
/**
 * Checks that the given annotation is of type
 * <code>{@value #ANN_SUITE}.{@value #ANN_SUITE_MEMBERS}</code>
 * and contains the given list of classes as (the only) argument,
 * in the same order.
 * 
 * @param  annMirror  annotation to be checked
 * @param  suiteMembers  list of fully qualified class names denoting
 *                       content of the test suite
 * @return  {@code true} if the annotation meets the described criteria,
 *          {@code false} otherwise
 */
private boolean checkSuiteMembersAnnotation(AnnotationMirror annMirror,
                                            List<String> suiteMembers,
                                            WorkingCopy workingCopy) {
    Map<? extends ExecutableElement,? extends AnnotationValue> annParams
            = annMirror.getElementValues();
    
    if (annParams.size() != 1) {
        return false;
    }
    
    AnnotationValue annValue = annParams.values().iterator().next();
    Object value = annValue.getValue();
    if (value instanceof java.util.List) {
        List<? extends AnnotationValue> items
                = (List<? extends AnnotationValue>) value;
        
        if (items.size() != suiteMembers.size()) {
            return false;
        }
        
        Types types = workingCopy.getTypes();
        Iterator<String> suiteMembersIt = suiteMembers.iterator();
        for (AnnotationValue item : items) {
            Name suiteMemberName = getAnnotationValueClassName(item, types);
            if (suiteMemberName == null) {
                return false;
            }
            if (!suiteMemberName.contentEquals(suiteMembersIt.next())) {
                return false;
            }
        }
        return true;
    }
    
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:49,代码来源:JUnit4TestGenerator.java

示例11: getAnnoType

import javax.lang.model.element.AnnotationValue; //导入方法依赖的package包/类
/** Get the annoType value from an @Test annotation mirror. */
static String getAnnoType(AnnotationMirror test) {
    AnnotationValue v = getValue(test, "annoType");
    TypeMirror m = (TypeMirror) v.getValue();
    return m.toString();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:7,代码来源:BasicAnnoTests.java

示例12: getExpect

import javax.lang.model.element.AnnotationValue; //导入方法依赖的package包/类
/** Get the expect value from an @Test annotation mirror. */
static String getExpect(AnnotationMirror test) {
    AnnotationValue v = getValue(test, "expect");
    return (String) v.getValue();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:6,代码来源:BasicAnnoTests.java

示例13: getIntegerValue

import javax.lang.model.element.AnnotationValue; //导入方法依赖的package包/类
/**
 * Tries to get the annotationValues value as Integer.
 *
 * @param annotationValue the value to get the value from.
 * @return the annotationValues value casted as Integer, or null if value has not the correct type.
 */
public static Integer getIntegerValue(AnnotationValue annotationValue) {
    return !isInteger(annotationValue) ? null : (Integer) annotationValue.getValue();
}
 
开发者ID:toolisticon,项目名称:annotation-processor-toolkit,代码行数:10,代码来源:AnnotationValueUtils.java

示例14: getFloatValue

import javax.lang.model.element.AnnotationValue; //导入方法依赖的package包/类
/**
 * Tries to get the annotationValues value as Float.
 *
 * @param annotationValue the value to get the value from.
 * @return the annotationValues value casted as Long, or null if value has not the correct type.
 */
public static Float getFloatValue(AnnotationValue annotationValue) {
    return !isFloat(annotationValue) ? null : (Float) annotationValue.getValue();
}
 
开发者ID:toolisticon,项目名称:annotation-processor-toolkit,代码行数:10,代码来源:AnnotationValueUtils.java

示例15: getDoubleValue

import javax.lang.model.element.AnnotationValue; //导入方法依赖的package包/类
/**
 * Tries to get the annotationValues value as Double.
 *
 * @param annotationValue the value to get the value from.
 * @return the annotationValues value casted as Long, or null if value has not the correct type.
 */
public static Double getDoubleValue(AnnotationValue annotationValue) {
    return !isDouble(annotationValue) ? null : (Double) annotationValue.getValue();
}
 
开发者ID:toolisticon,项目名称:annotation-processor-toolkit,代码行数:10,代码来源:AnnotationValueUtils.java


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