Java Code Examples for org.jboss.jandex.ClassInfo#nestingType()

The following examples show how to use org.jboss.jandex.ClassInfo#nestingType() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DotNames.java    From quarkus with Apache License 2.0 5 votes vote down vote up
/**
 * 
 * @param clazz
 * @return the simple name for the given top-level or nested class
 */
public static String simpleName(ClassInfo clazz) {
    switch (clazz.nestingType()) {
        case TOP_LEVEL:
            return simpleName(clazz.name());
        case INNER:
            // Nested class
            // com.foo.Foo$Bar -> Bar
            return clazz.simpleName();
        default:
            throw new IllegalStateException("Unsupported nesting type: " + clazz);
    }
}
 
Example 2
Source File: ValueResolverGenerator.java    From quarkus with Apache License 2.0 5 votes vote down vote up
/**
 * 
 * @param clazz
 * @return the simple name for the given top-level or nested class
 */
static String simpleName(ClassInfo clazz) {
    switch (clazz.nestingType()) {
        case TOP_LEVEL:
            return simpleName(clazz.name());
        case INNER:
            // Nested class
            // com.foo.Foo$Bar -> Bar
            return clazz.simpleName();
        default:
            throw new IllegalStateException("Unsupported nesting type: " + clazz);
    }
}
 
Example 3
Source File: TypeUtil.java    From serianalyzer with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @param i
 * @return
 * @throws SerianalyzerException
 */
static String makeSignature ( MethodInfo i, boolean fix ) throws SerianalyzerException {

    StringBuilder sb = new StringBuilder();
    sb.append('(');
    ClassInfo declaringImpl = i.declaringClass();
    if ( fix && "<init>".equals(i.name()) && declaringImpl.nestingType() == NestingType.INNER ) { //$NON-NLS-1$
        // there seems to be some sort of bug, missing the the outer instance parameter in the constructor
        if ( !Modifier.isStatic(declaringImpl.flags()) ) {
            org.jboss.jandex.Type enclosingClass = org.jboss.jandex.Type.create(declaringImpl.enclosingClass(), Kind.CLASS);
            org.jboss.jandex.Type firstArg = i.parameters().size() > 0 ? i.parameters().get(0) : null;
            if ( firstArg instanceof TypeVariable ) {
                firstArg = firstArg.asTypeVariable().bounds().get(0);
            }
            if ( firstArg == null || !firstArg.equals(enclosingClass) ) {
                sb.append(toString(enclosingClass));
            }
        }
    }

    for ( org.jboss.jandex.Type p : i.parameters() ) {
        sb.append(toString(p));
    }
    sb.append(')');
    sb.append(toString(i.returnType()));
    return sb.toString();
}