// Path: src/main/java/eme/model/datatypes/AccessLevelModifier.java
// public enum AccessLevelModifier {
//     /**
//      * Represents the default Java modifier.
//      */
//     NO_MODIFIER,
// 
//     /**
//      * Represents the Java modifier <code>private</code>.
//      */
//     PRIVATE,
// 
//     /**
//      * Represents the Java modifier <code>protected</code>.
//      */
//     PROTECTED,
// 
//     /**
//      * Represents the Java modifier <code>public</code>.
//      */
//     PUBLIC;
// }
// 
// Path: src/main/java/eme/model/datatypes/WildcardStatus.java
// public enum WildcardStatus {
//     /**
//      * Is not a wild card data type.
//      */
//     NO_WILDCARD,
// 
//     /**
//      * Is a basic wild card data type like <code>?</code>
//      */
//     UNBOUND,
// 
//     /**
//      * Is a wild card data type with lower bound like <code>? super SomeClass/<code>
//      */
//     LOWER_BOUND,
// 
//     /**
//      * Is a wild card data type with upper bound like <code>? extends SomeClass/<code>
//      */
//     UPPER_BOUND;
// }


import org.eclipse.jdt.core.Flags;
import org.eclipse.jdt.core.IMember;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.Signature;
import eme.model.datatypes.AccessLevelModifier;
import eme.model.datatypes.WildcardStatus;
package eme.extractor;



/**
 * This class offers simple adapter methods for JDT functionality that makes code unreadable.
 * @author Timur Saglam
 */
public final class JDTUtil {

    /**
     * Private constructor for static class.
     */
    private JDTUtil() {
        // Private constructor.
    }

    /**
     * Determines the access level modifier of an {@link IMember} and returns it as {@link AccessLevelModifier}.
     * @param member is the {@link IMember}.
     * @return the {@link AccessLevelModifier}.
     * @throws JavaModelException if there is a problem with the JDT API.
     */
    public static AccessLevelModifier getModifier(IMember member) throws JavaModelException {
        int flags = member.getFlags();
        if (Flags.isPublic(flags)) {
            return AccessLevelModifier.PUBLIC;
        } else if (Flags.isPrivate(flags)) {
            return AccessLevelModifier.PRIVATE;
        } else if (Flags.isProtected(flags)) {
            return AccessLevelModifier.PROTECTED;
        } else if (member.getDeclaringType().isInterface()) {
            return AccessLevelModifier.PUBLIC; // default visibility in interface is public.
        }
        return AccessLevelModifier.NO_MODIFIER; // default visibility in any other case is package visibility.
    }

    /**
     * Returns the fully qualified name of an {@link IType}, including qualification for any containing types and
     * packages. The character '.' is used as enclosing type separator.
     * @param type is the {@link IType}.
     * @return the fully qualified name.
     * @see eme.generator.saving.AbstractSavingStrategy#filePath()
     */
    public static String getName(IType type) {
        return type.getFullyQualifiedName('.');
    }

    /**
     * Determines the {@link WildcardStatus} of an signature string.
     * @param signature is the signature string.
     * @return the {@link WildcardStatus}.
     */
    public static WildcardStatus getWildcardStatus(String signature) {
        if (signature.startsWith(Character.toString(Signature.C_STAR))) {
            return WildcardStatus.UNBOUND; // is unbound wildcard
        } else if (signature.startsWith(Character.toString(Signature.C_EXTENDS))) {
            return WildcardStatus.UPPER_BOUND; // is upper bound wildcard
        } else if (signature.startsWith(Character.toString(Signature.C_SUPER))) {
// Path: src/main/java/eme/model/datatypes/AccessLevelModifier.java
// public enum AccessLevelModifier {
//     /**
//      * Represents the default Java modifier.
//      */
//     NO_MODIFIER,
// 
//     /**
//      * Represents the Java modifier <code>private</code>.
//      */
//     PRIVATE,
// 
//     /**
//      * Represents the Java modifier <code>protected</code>.
//      */
//     PROTECTED,
// 
//     /**
//      * Represents the Java modifier <code>public</code>.
//      */
//     PUBLIC;
// }
// 
// Path: src/main/java/eme/model/datatypes/WildcardStatus.java
// public enum WildcardStatus {
//     /**
//      * Is not a wild card data type.
//      */
//     NO_WILDCARD,
// 
//     /**
//      * Is a basic wild card data type like <code>?</code>
//      */
//     UNBOUND,
// 
//     /**
//      * Is a wild card data type with lower bound like <code>? super SomeClass/<code>
//      */
//     LOWER_BOUND,
// 
//     /**
//      * Is a wild card data type with upper bound like <code>? extends SomeClass/<code>
//      */
//     UPPER_BOUND;
// }


// Path: src/main/java/eme/extractor/JDTUtil.java
import org.eclipse.jdt.core.Flags;
import org.eclipse.jdt.core.IMember;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.Signature;
import eme.model.datatypes.AccessLevelModifier;
import eme.model.datatypes.WildcardStatus;

package eme.extractor;



/**
 * This class offers simple adapter methods for JDT functionality that makes code unreadable.
 * @author Timur Saglam
 */
public final class JDTUtil {

    /**
     * Private constructor for static class.
     */
    private JDTUtil() {
        // Private constructor.
    }

    /**
     * Determines the access level modifier of an {@link IMember} and returns it as {@link AccessLevelModifier}.
     * @param member is the {@link IMember}.
     * @return the {@link AccessLevelModifier}.
     * @throws JavaModelException if there is a problem with the JDT API.
     */
    public static AccessLevelModifier getModifier(IMember member) throws JavaModelException {
        int flags = member.getFlags();
        if (Flags.isPublic(flags)) {
            return AccessLevelModifier.PUBLIC;
        } else if (Flags.isPrivate(flags)) {
            return AccessLevelModifier.PRIVATE;
        } else if (Flags.isProtected(flags)) {
            return AccessLevelModifier.PROTECTED;
        } else if (member.getDeclaringType().isInterface()) {
            return AccessLevelModifier.PUBLIC; // default visibility in interface is public.
        }
        return AccessLevelModifier.NO_MODIFIER; // default visibility in any other case is package visibility.
    }

    /**
     * Returns the fully qualified name of an {@link IType}, including qualification for any containing types and
     * packages. The character '.' is used as enclosing type separator.
     * @param type is the {@link IType}.
     * @return the fully qualified name.
     * @see eme.generator.saving.AbstractSavingStrategy#filePath()
     */
    public static String getName(IType type) {
        return type.getFullyQualifiedName('.');
    }

    /**
     * Determines the {@link WildcardStatus} of an signature string.
     * @param signature is the signature string.
     * @return the {@link WildcardStatus}.
     */
    public static WildcardStatus getWildcardStatus(String signature) {
        if (signature.startsWith(Character.toString(Signature.C_STAR))) {
            return WildcardStatus.UNBOUND; // is unbound wildcard
        } else if (signature.startsWith(Character.toString(Signature.C_EXTENDS))) {
            return WildcardStatus.UPPER_BOUND; // is upper bound wildcard
        } else if (signature.startsWith(Character.toString(Signature.C_SUPER))) {
            return WildcardStatus.LOWER_BOUND; // is lower bound wildcard