Example usage for org.eclipse.jdt.internal.core ResolvedBinaryType getKey

List of usage examples for org.eclipse.jdt.internal.core ResolvedBinaryType getKey

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.core ResolvedBinaryType getKey.

Prototype

@Override
    public String getKey() 

Source Link

Usage

From source file:com.halware.nakedide.eclipse.core.util.TypeUtils.java

License:Open Source License

@SuppressWarnings("restriction")
static boolean hasAnnotation(ITypeBinding typeBinding, String annotationTypeName) {

    if (typeBinding == null) {
        return false;
    }//w ww. j av a  2s  . c o  m

    String annotationTypeSig = ("L" + annotationTypeName + ";");

    IAnnotationBinding[] annotations = typeBinding.getAnnotations();
    for (IAnnotationBinding annotationBinding : annotations) {
        IJavaElement javaElement = annotationBinding.getJavaElement();
        if (javaElement == null) {
            continue;
        }
        if (!(javaElement instanceof org.eclipse.jdt.internal.core.ResolvedBinaryType)) {
            continue;
        }
        org.eclipse.jdt.internal.core.ResolvedBinaryType rbt = (org.eclipse.jdt.internal.core.ResolvedBinaryType) javaElement;
        BindingKey bindingKey = new BindingKey(rbt.getKey());
        if (annotationTypeSig.equals(bindingKey.toSignature())) {
            return true;
        }
    }
    return false;
}