當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。