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


Java Annotation.isNormalAnnotation方法代码示例

本文整理汇总了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;
}
 
开发者ID:awltech,项目名称:eclipse-optimus,代码行数:35,代码来源:JavaCodeHelper.java

示例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();
}
 
开发者ID:awltech,项目名称:eclipse-optimus,代码行数:28,代码来源:ASTHelper.java

示例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;
}
 
开发者ID:awltech,项目名称:eclipse-optimus,代码行数:15,代码来源:ASTHelper.java

示例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);
	}
}
 
开发者ID:awltech,项目名称:eclipse-optimus,代码行数:14,代码来源:MethodDeclarationMerger.java

示例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);
				}
			}
		}
	}
}
 
开发者ID:awltech,项目名称:eclipse-optimus,代码行数:79,代码来源:DefaultMergingStrategy.java


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