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


Java ReferenceBinding.isAnnotationType方法代码示例

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


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

示例1: createAnnotationMirror

import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; //导入方法依赖的package包/类
private AnnotationMirrorImpl createAnnotationMirror(String annoTypeName, AnnotationBinding annoInstance) {
	ReferenceBinding binding = annoInstance.getAnnotationType();
	if (binding != null && binding.isAnnotationType() ) {
		char[] qName;
		if (binding.isMemberType()) {
			annoTypeName = annoTypeName.replace('$', '.');
			qName = CharOperation.concatWith(binding.enclosingType().compoundName, binding.sourceName, '.');
			CharOperation.replace(qName, '$', '.');
		} else {
			qName = CharOperation.concatWith(binding.compoundName, '.');
		}
		if(annoTypeName.equals(new String(qName)) ){
			return (AnnotationMirrorImpl)_env.getFactory().newAnnotationMirror(annoInstance);
		}
	}
	return null;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:18,代码来源:Factory.java

示例2: getKind

import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; //导入方法依赖的package包/类
@Override
public ElementKind getKind() {
	if (null != _kindHint) {
		return _kindHint;
	}
	ReferenceBinding refBinding = (ReferenceBinding)_binding;
	// The order of these comparisons is important: e.g., enum is subset of class
	if (refBinding.isEnum()) {
		return ElementKind.ENUM;
	}
	else if (refBinding.isAnnotationType()) {
		return ElementKind.ANNOTATION_TYPE;
	}
	else if (refBinding.isInterface()) {
		return ElementKind.INTERFACE;
	}
	else if (refBinding.isClass()) {
		return ElementKind.CLASS;
	}
	else {
		throw new IllegalArgumentException("TypeElement " + new String(refBinding.shortReadableName()) +  //$NON-NLS-1$
				" has unexpected attributes " + refBinding.modifiers); //$NON-NLS-1$
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:25,代码来源:TypeElementImpl.java

示例3: newProxyInstance

import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; //导入方法依赖的package包/类
@SuppressWarnings("unchecked") // for cast of newProxyInstance() to A
@Override
public <A extends Annotation> A getAnnotation(Class<A> annotationClass) {
	AnnotationBinding[] annoInstances = getAnnotationBindings();
	if( annoInstances == null || annoInstances.length == 0 || annotationClass == null ) 
		return null;

	String annoTypeName = annotationClass.getName();
	if( annoTypeName == null ) return null;
	annoTypeName = annoTypeName.replace('$', '.');
	for( AnnotationBinding annoInstance : annoInstances) {
		if (annoInstance == null)
			continue;
		ReferenceBinding binding = annoInstance.getAnnotationType();
		if ( binding != null && binding.isAnnotationType() ) {
			char[] qName;
			if (binding.isMemberType()) {
				qName = CharOperation.concatWith(binding.enclosingType().compoundName, binding.sourceName, '.');
				CharOperation.replace(qName, '$', '.');
			} else {
				qName = CharOperation.concatWith(binding.compoundName, '.');
			}
			if( annoTypeName.equals(new String(qName)) ){
				AnnotationMirrorImpl annoMirror =
					(AnnotationMirrorImpl)_env.getFactory().newAnnotationMirror(annoInstance);
				return (A)Proxy.newProxyInstance(annotationClass.getClassLoader(),
						new Class[]{ annotationClass }, annoMirror );
			}
		}
	}
	return null; 
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:33,代码来源:ElementImpl.java


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