Java Annotation findQualifiedTypeName(Annotation annotation)

PreviousNext

//package com.java2s;
/*/*w  w    w  . d  e  m  o  2 s  .    c  om  */
 * Copyright 2016 the original author or authors
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 */

import org.eclipse.jdt.core.dom.Annotation;

import org.eclipse.jdt.core.dom.ITypeBinding;
import org.eclipse.jdt.core.dom.Name;

public class Main {
    private static String findQualifiedTypeName(Annotation annotation) {
        Name name = annotation.getTypeName();
        if (name.isSimpleName()) {
            ITypeBinding typeBinding = annotation.resolveTypeBinding();
            if (typeBinding == null) {
                return null;
            }
            return typeBinding.getQualifiedName();
        }
        return name.getFullyQualifiedName();
    }
}
PreviousNext

Related