public static TypeDeclaration getTypeDeclaration(CompilationUnit compilationUnit, String typeName)
            throws TypeDeclarationNotFoundException {
        requireNonNull(compilationUnit, "compilation unit");
        requireNonNull(typeName, "class name");

        int index = typeName.lastIndexOf('.');
        String packageName = index > 0 ? typeName.substring(0, index) : "";
        if (!matchesPackage(compilationUnit.getPackage(), packageName)) {
            throw new TypeDeclarationNotFoundException(compilationUnit, typeName, "The package '" + packageName
                    + "' doesn't match the package of the compilation unit.");
        }

        TypeDeclaration type = searchTypeDeclaration(compilationUnit.types(), typeName.substring(index + 1));
        if (type == null) {
            throw new TypeDeclarationNotFoundException(compilationUnit, typeName);
        }
        return type;
    }
public static TypeDeclaration getTypeDeclaration ( CompilationUnit compilationUnit , String typeName ) throws TypeDeclarationNotFoundException { requireNonNull ( compilationUnit , "compilation unit" ) ; requireNonNull ( typeName , "class name" ) ; int index = typeName . lastIndexOf ( '.' ) ; String packageName = index > 0 ? typeName . substring ( 0 , index ) : "" ; if ( ! matchesPackage ( compilationUnit . getPackage ( ) , packageName ) ) { throw new TypeDeclarationNotFoundException ( compilationUnit , typeName , "The package '" + packageName + "' doesn't match the package of the compilation unit." ) ; } TypeDeclaration type = searchTypeDeclaration ( compilationUnit . types ( ) , typeName . substring ( index + 1 ) ) ; if ( type == null ) { throw new TypeDeclarationNotFoundException ( compilationUnit , typeName ) ; } return type ; }
Returns the <CODE>TypeDeclaration</CODE> for the specified type name. The
type has to be declared in the specified <CODE>CompilationUnit</CODE>.

@param compilationUnit
The <CODE>CompilationUnit</CODE>, where the
<CODE>TypeDeclaration</CODE> is declared in.
@param typeName
The qualified class name to search for.
@return the <CODE>TypeDeclaration</CODE> found in the specified
<CODE>CompilationUnit</CODE>.
@throws TypeDeclarationNotFoundException
if no matching <CODE>TypeDeclaration</CODE> was found.