本文整理汇总了Java中org.eclipse.jdt.core.dom.Annotation.isNormalAnnotation方法的典型用法代码示例。如果您正苦于以下问题:Java Annotation.isNormalAnnotation方法的具体用法?Java Annotation.isNormalAnnotation怎么用?Java Annotation.isNormalAnnotation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.dom.Annotation
的用法示例。
在下文中一共展示了Annotation.isNormalAnnotation方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkAnnotationContent
import org.eclipse.jdt.core.dom.Annotation; //导入方法依赖的package包/类
/**
* Return true if the annotation content matches the input map (@Foo(f1 = v1
* , f2 = v2)
*
* @param annotation
* input annotation to check
* @param content
* a Map object containing as key the expected member name and as
* value the expected member value
* @return true if the annotation is a normal annotation and if the content
* matches the content parameter, false otherwise
*/
@SuppressWarnings("unchecked")
public static boolean checkAnnotationContent(Annotation annotation, Map<String, Object> content) {
boolean correct = false;
// Test if this annotation is a Normal Member Annotation
if (annotation != null && annotation.isNormalAnnotation()) {
List<MemberValuePair> values = ((NormalAnnotation) annotation).values();
correct = true;
for (int inc = 0; inc < values.size() && correct; inc++) {
MemberValuePair mvp = values.get(inc);
String memberName = mvp.getName().getFullyQualifiedName();
Object contentValue = content.get(memberName);
correct = contentValue != null;
Expression memberValue = mvp.getValue();
correct = checkSingleAnnotationValue(memberValue, contentValue);
}
}
return correct;
}
示例2: getHashCodeFromGeneratedAnnotation
import org.eclipse.jdt.core.dom.Annotation; //导入方法依赖的package包/类
/**
* Return the hashCode of a Body Declaration (from @Generated annotation)
*/
public static int getHashCodeFromGeneratedAnnotation(BodyDeclaration bodyDeclaration) {
Annotation generatedAnnotation = ASTHelper.getAnnotation(JavaCodeHelper.GENERATED_SIMPLECLASSNAME, bodyDeclaration);
if (generatedAnnotation == null) {
// @Generated not found, the BodyDeclaration must not be merged
throw new UnsupportedOperationException();
}
if (generatedAnnotation.isNormalAnnotation()) {
String stringHashcode = GeneratedAnnotationHelper.getGeneratedAnnotationHashcode((NormalAnnotation) generatedAnnotation);
if(stringHashcode != null) {
try {
return Integer.parseInt(stringHashcode);
}
catch (NumberFormatException e) {
Activator.getDefault().logError("Hashcode can't be parsed to int in: \n" + bodyDeclaration.toString(), e);
return -1;
}
}
}
// If the hashCode cannot be found, throw an IllegalArgumentException
throw new IllegalArgumentException();
}
示例3: getUniqueIdFromGeneratedAnnotation
import org.eclipse.jdt.core.dom.Annotation; //导入方法依赖的package包/类
/**
* Return the Unique ID of a Body Declaration (from @Generated annotation)
*/
public static String getUniqueIdFromGeneratedAnnotation(BodyDeclaration bodyDeclaration) {
Annotation generatedAnnotation = ASTHelper.getAnnotation(JavaCodeHelper.GENERATED_SIMPLECLASSNAME, bodyDeclaration);
if (generatedAnnotation != null && generatedAnnotation.isNormalAnnotation()) {
String stringHashcode = GeneratedAnnotationHelper.getGeneratedAnnotationUniqueId((NormalAnnotation) generatedAnnotation);
return stringHashcode;
}
// If the Unique ID cannot be found, return null
return null;
}
示例4: replaceGeneratedAnnotation
import org.eclipse.jdt.core.dom.Annotation; //导入方法依赖的package包/类
/**
* Replace @Generated annotation
*/
private void replaceGeneratedAnnotation(MethodDeclaration existingMethod, MethodDeclaration generatedMethod) {
Annotation existingAnnotation = ASTHelper.getAnnotation(JavaCodeHelper.GENERATED_SIMPLECLASSNAME,
existingMethod);
Annotation generatedAnnotation = ASTHelper.getAnnotation(JavaCodeHelper.GENERATED_SIMPLECLASSNAME,
generatedMethod);
if (existingAnnotation != null && generatedAnnotation != null && generatedAnnotation.isNormalAnnotation()) {
astr.replace(existingAnnotation, generatedAnnotation, null);
}
}
示例5: mergeAnnotationAttributes
import org.eclipse.jdt.core.dom.Annotation; //导入方法依赖的package包/类
/**
* Annotation attributes handlings for annotation's type located in the
* generated annotation property file.
*
* @param annotationInTheExistingFragment
* @param existingAnnotation
* @param lw
* @param generatedAnnotations
* @param annoName
*/
private void mergeAnnotationAttributes(Annotation annotationInTheExistingFragment,
Annotation annotationInTheGeneratedFragment, ListRewrite lw) {
if (annotationInTheExistingFragment.isMarkerAnnotation()) {
/*
* The annotation used inside the existing fragment is a marker
* annotation (annotation without attribute)
*/
if (!annotationInTheGeneratedFragment.isMarkerAnnotation()) {
/*
* The annotation used inside the generated fragment contains
* one or many attributes. The annotation used inside the
* generated fragment must be used in the result
*/
lw.replace(annotationInTheExistingFragment, annotationInTheGeneratedFragment, null);
}
} else {
if (annotationInTheExistingFragment.isSingleMemberAnnotation()) {
/*
* The annotation used inside the existing fragment is a single
* member annotation (annotation without only one attribute)
*/
if (annotationInTheGeneratedFragment.isSingleMemberAnnotation()) {
/*
* The annotation used inside the generated fragment
* contains one value. Existing value must be replaced by
* generated value.
*/
this.astr.replace(annotationInTheExistingFragment, annotationInTheGeneratedFragment,
null);
} else {
if (annotationInTheGeneratedFragment.isNormalAnnotation()) {
/*
* The annotation used inside the generated fragment
* contains several attributes. Existing value must be
* replaced by generated value.
*/
lw.replace(annotationInTheExistingFragment,
annotationInTheGeneratedFragment, null);
}
}
} else {
/*
* The annotation used inside the existing fragment is a normal
* annotation (annotation with several attributes)
*/
if (annotationInTheGeneratedFragment.isSingleMemberAnnotation()) {
/*
* What should be done in that case ? The existing
* annotation has been probably enhance => Let the existing
* content as before.
*/
} else {
if (annotationInTheGeneratedFragment.isNormalAnnotation()) {
/*
* The annotation used inside the generated fragment
* contains several attributes. Existing and generated
* annotations must be merged.
*/
this.mergeAnnotationAttribute(
(NormalAnnotation) annotationInTheExistingFragment,
(NormalAnnotation) annotationInTheGeneratedFragment);
}
}
}
}
}