Example usage for com.google.gwt.core.ext.typeinfo JClassType getName

List of usage examples for com.google.gwt.core.ext.typeinfo JClassType getName

Introduction

In this page you can find the example usage for com.google.gwt.core.ext.typeinfo JClassType getName.

Prototype

String getName();

Source Link

Usage

From source file:cc.alcina.framework.entity.gwtsynth.ClientReflectionGenerator.java

License:Apache License

/**
 * Since overridden parent annotations are potentially useful, we don't use
 * standard overriding behaviour/*from w  ww  .j  a  v a 2  s.c om*/
 *
 * @throws ClassNotFoundException
 */
private Map<JClassType, Set<RegistryLocation>> getRegistryAnnotations(TypeOracle typeOracle)
        throws ClassNotFoundException {
    HashMap<JClassType, Set<RegistryLocation>> results = new HashMap<JClassType, Set<RegistryLocation>>();
    JClassType[] types = typeOracle.getTypes();
    for (JClassType jct : types) {
        if (jct.getName().matches("(?i).*AlcinaBeanSerializerC.*")) {
            int debug = 3;
        }
        if ((jct.isAnnotationPresent(RegistryLocation.class)
                || jct.isAnnotationPresent(RegistryLocations.class)) && !jct.isAbstract()) {
            Set<RegistryLocation> rls = getClassAnnotations(jct, RegistryLocation.class, true);
            Set<RegistryLocations> rlsSet = getClassAnnotations(jct, RegistryLocations.class, true);
            for (RegistryLocations rlcs : rlsSet) {
                for (RegistryLocation rl : rlcs.value()) {
                    rls.add(rl);
                }
            }
            rls = new LinkedHashSet<RegistryLocation>(rls);
            CollectionFilters.filterInPlace(rls, CLIENT_VISIBLE_ANNOTATION_FILTER);
            rls = Registry.filterForRegistryPointUniqueness(rls);
            if (!rls.isEmpty() && !ignore(jct)) {
                results.put(jct, rls);
            }
        }
    }
    return results;
}

From source file:ch.unifr.pai.twice.comm.serverPush.rebind.RemoteEventDeSerializerGenerator.java

License:Apache License

@Override
public String generate(TreeLogger logger, GeneratorContext context, String typeName)
        throws UnableToCompleteException {
    // Build a new class, that implements a "paintScreen" method
    JClassType classType;/*from   ww  w.j ava 2s  .  c  om*/

    try {
        classType = context.getTypeOracle().getType(typeName);
        // Here you would retrieve the metadata based on typeName for this
        // Screen
        SourceWriter src = getSourceWriter(classType, context, logger);
        if (src != null) {
            src.println("@Override");
            src.println(
                    "public " + RemoteEvent.class.getName() + "<?> deserialize(" + JSONObject.class.getName()
                            + " o, String t, String string, " + TWICESecurityManager.class.getName()
                            + " securityManager) throws " + MessagingException.class.getName() + " {");
            JClassType abstractRemoteEvent = context.getTypeOracle().findType(RemoteEvent.class.getName());
            src.println("if(t==null){");
            src.println("return null;");
            src.println("}");
            for (JClassType subType : abstractRemoteEvent.getSubtypes()) {
                if (!subType.getPackage().getName()
                        .contains(ch.unifr.pai.twice.comm.serverPush.client.RemoteEventDeserializer.class
                                .getPackage().getName())
                        && !subType.getName().endsWith("Impl")) {
                    src.println("else if(t.equals(" + subType.getQualifiedSourceName() + ".class.getName())){");
                    src.println(subType.getQualifiedSourceName() + " event = " + GWT.class.getName()
                            + ".create(" + subType.getQualifiedSourceName() + ".class);");
                    src.println("return event.deserialize(string, securityManager);");
                    src.println("}");
                }
            }
            src.println("return null;}");
            src.commit(logger);
        }
        return typeName + "Impl";
    } catch (NotFoundException e) {
        e.printStackTrace();
    }
    return null;
}

From source file:ch.unifr.pai.twice.comm.serverPush.rebind.RemoteEventDeSerializerGenerator.java

License:Apache License

public SourceWriter getSourceWriter(JClassType classType, GeneratorContext context, TreeLogger logger) {
    String packageName = classType.getPackage().getName();
    String simpleName = classType.getSimpleSourceName() + "Impl";
    ClassSourceFileComposerFactory composer = new ClassSourceFileComposerFactory(packageName, simpleName);
    composer.setSuperclass(classType.getName());

    composer.addImport(classType.getQualifiedSourceName());

    // Need to add whatever imports your generated class needs.
    // composer.addImport("com.google.gwt.user.client.Window");
    // composer.addImport("com.google.gwt.user.client.rpc.AsyncCallback");
    // composer.addImport("com.google.gwt.user.client.ui.Button");
    // composer.addImport("com.google.gwt.user.client.ui.RootPanel");

    PrintWriter printWriter = context.tryCreate(logger, packageName, simpleName);
    if (printWriter == null) {
        return null;
    } else {/* www .  j  a  va 2 s . c om*/
        SourceWriter sw = composer.createSourceWriter(context, printWriter);
        return sw;
    }
}

From source file:ch.unifr.pai.twice.module.rebind.TWICEModuleGenerator.java

License:Apache License

/**
 * Define the class to be generated./* www  .  j a va  2s  . c  o  m*/
 * 
 * @param classType
 * @param context
 * @param logger
 * @return
 */
public SourceWriter getSourceWriter(JClassType classType, GeneratorContext context, TreeLogger logger) {
    String packageName = classType.getPackage().getName();
    String simpleName = classType.getSimpleSourceName() + "Impl";
    ClassSourceFileComposerFactory composer = new ClassSourceFileComposerFactory(packageName, simpleName);
    composer.setSuperclass(classType.getName());
    composer.addImplementedInterface(TWICEModuleInstantiator.class.getName() + "<"
            + getGenericClass(classType).getQualifiedSourceName() + ">");

    PrintWriter printWriter = context.tryCreate(logger, packageName, simpleName);
    if (printWriter == null) {
        return null;
    } else {
        SourceWriter sw = composer.createSourceWriter(context, printWriter);
        return sw;
    }
}

From source file:com.allen_sauer.gwt.log.rebind.LogMessageFormatterGenerator.java

License:Apache License

@Override
public String generate(TreeLogger logger, GeneratorContext context, String typeName)
        throws UnableToCompleteException {
    TypeOracle typeOracle = context.getTypeOracle();

    JClassType userType;
    try {/*from w ww.  j  ava  2  s . com*/
        userType = typeOracle.getType(typeName);
    } catch (NotFoundException e) {
        logger.log(TreeLogger.ERROR, "OOPS", e);
        throw new UnableToCompleteException();
    }
    String packageName = userType.getPackage().getName();
    String className = userType.getName();

    JClassType remoteService = typeOracle.findType(typeName);
    if (remoteService == null) {
        logger.log(TreeLogger.ERROR, "Unable to find metadata for type '" + typeName + "'", null);
        throw new UnableToCompleteException();
    }

    if (remoteService.isInterface() == null) {
        logger.log(TreeLogger.ERROR, remoteService.getQualifiedSourceName() + " is not an interface", null);
        throw new UnableToCompleteException();
    }
    ClassSourceFileComposerFactory composerFactory = new ClassSourceFileComposerFactory(packageName,
            className + "Impl");
    composerFactory.addImplementedInterface(remoteService.getQualifiedSourceName());

    composerFactory.addImport(Date.class.getName());
    composerFactory.addImport(GWT.class.getName());
    composerFactory.addImport(LogUtil.class.getName());
    composerFactory.addImport(Duration.class.getName());

    PrintWriter pw = context.tryCreate(logger, packageName, className + "Impl");
    if (pw != null) {
        SourceWriter sw = composerFactory.createSourceWriter(context, pw);

        PropertyOracle propertyOracle = context.getPropertyOracle();
        String logPattern;
        try {
            ConfigurationProperty logPatternProperty = propertyOracle
                    .getConfigurationProperty(PROPERTY_LOG_PATTERN);
            List<String> values = logPatternProperty.getValues();
            logPattern = values.get(0);
        } catch (BadPropertyValueException e) {
            logger.log(TreeLogger.ERROR, "Unable to find value for '" + PROPERTY_LOG_PATTERN + "'", e);
            throw new UnableToCompleteException();
        }

        sw.println();
        sw.println("private double BIG_BANG = Duration.currentTimeMillis();");

        sw.println();
        sw.println(
                "public String format(String logLevelText, String category, String message, Throwable throwable) {");
        sw.indent();
        sw.println("if (category == null) {");
        sw.indent();
        sw.println("category = \"<null category>\";");
        sw.outdent();
        sw.println("}");
        sw.println("if (message == null) {");
        sw.indent();
        sw.println("message = \"<null message>\";");
        sw.outdent();
        sw.println("}");
        sw.println(logPatternToCode(logPattern));
        sw.outdent();
        sw.println("}");

        sw.commit(logger);
    }
    return composerFactory.getCreatedClassName();
}

From source file:com.allen_sauer.gwt.log.rebind.RemoteLoggerConfigGenerator.java

License:Apache License

@Override
public String generate(TreeLogger logger, GeneratorContext context, String typeName)
        throws UnableToCompleteException {
    TypeOracle typeOracle = context.getTypeOracle();

    JClassType userType;
    try {/* w  ww . j  a  v a 2  s  . com*/
        userType = typeOracle.getType(typeName);
    } catch (NotFoundException e) {
        logger.log(TreeLogger.ERROR, "OOPS", e);
        throw new UnableToCompleteException();
    }
    String packageName = userType.getPackage().getName();
    String className = userType.getName();

    JClassType remoteService = typeOracle.findType(typeName);
    if (remoteService == null) {
        logger.log(TreeLogger.ERROR, "Unable to find metadata for type '" + typeName + "'", null);
        throw new UnableToCompleteException();
    }

    if (remoteService.isInterface() == null) {
        logger.log(TreeLogger.ERROR, remoteService.getQualifiedSourceName() + " is not an interface", null);
        throw new UnableToCompleteException();
    }
    ClassSourceFileComposerFactory composerFactory = new ClassSourceFileComposerFactory(packageName,
            className + "Impl");
    composerFactory.addImplementedInterface(remoteService.getQualifiedSourceName());

    PrintWriter pw = context.tryCreate(logger, packageName, className + "Impl");
    if (pw != null) {
        SourceWriter sw = composerFactory.createSourceWriter(context, pw);

        PropertyOracle propertyOracle = context.getPropertyOracle();
        String logUrl;
        try {
            ConfigurationProperty logPatternProperty = propertyOracle
                    .getConfigurationProperty(PROPERTY_LOG_URL);
            List<String> values = logPatternProperty.getValues();
            logUrl = values.get(0);
        } catch (BadPropertyValueException e) {
            logger.log(TreeLogger.ERROR, "Unable to find value for '" + PROPERTY_LOG_URL + "'", e);
            throw new UnableToCompleteException();
        }

        sw.println();
        sw.println("public String serviceEntryPointUrl() {");
        sw.indent();

        if (logUrl == null) {
            sw.println("return null;");
        } else {
            sw.println("return \"" + logUrl.trim() + "\";");
        }

        sw.outdent();
        sw.println("}");

        sw.commit(logger);
    }
    return composerFactory.getCreatedClassName();
}

From source file:com.allen_sauer.gwt.voices.crowd.rebind.GwtUserAgentProviderGenerator.java

License:Apache License

@Override
public String generate(TreeLogger logger, GeneratorContext context, String typeName)
        throws UnableToCompleteException {
    TypeOracle typeOracle = context.getTypeOracle();

    JClassType userType;
    try {/*  www.  j  av a  2 s . co  m*/
        userType = typeOracle.getType(typeName);
    } catch (NotFoundException e) {
        logger.log(TreeLogger.ERROR, "OOPS", e);
        throw new UnableToCompleteException();
    }
    String packageName = userType.getPackage().getName();
    String className = userType.getName();

    JClassType remoteService = typeOracle.findType(typeName);
    if (remoteService == null) {
        logger.log(TreeLogger.ERROR, "Unable to find metadata for type '" + typeName + "'", null);
        throw new UnableToCompleteException();
    }

    if (remoteService.isInterface() == null) {
        logger.log(TreeLogger.ERROR, remoteService.getQualifiedSourceName() + " is not an interface", null);
        throw new UnableToCompleteException();
    }
    ClassSourceFileComposerFactory composerFactory = new ClassSourceFileComposerFactory(packageName,
            className + "Impl");
    composerFactory.addImplementedInterface(remoteService.getQualifiedSourceName());

    PrintWriter pw = context.tryCreate(logger, packageName, className + "Impl");
    if (pw != null) {
        SourceWriter sw = composerFactory.createSourceWriter(context, pw);

        PropertyOracle propertyOracle = context.getPropertyOracle();
        String userAgent;
        try {
            SelectionProperty userAgentProperty = propertyOracle.getSelectionProperty(logger,
                    PROPERTY_USER_AGENT);

            // ALWAYS RETURNS 'gecko'
            userAgent = userAgentProperty.getCurrentValue();
        } catch (BadPropertyValueException e) {
            logger.log(TreeLogger.ERROR, "Unable to find value for '" + PROPERTY_USER_AGENT + "'", e);
            throw new UnableToCompleteException();
        }

        sw.println();
        sw.println("public String getGwtUserAgent() {");
        sw.indent();

        if (userAgent == null) {
            sw.println("return null;");
        } else {
            sw.println("return \"" + userAgent + "\";");
        }

        sw.outdent();
        sw.println("}\n");

        sw.commit(logger);
    }
    return composerFactory.getCreatedClassName();
}

From source file:com.artemis.gwtref.gen.ReflectionCacheSourceCreator.java

License:Apache License

private String createTypeGenerator(JType t) {
    buffer.setLength(0);//from   w w w.  ja va 2  s. c o  m
    String varName = "t";
    if (t instanceof JPrimitiveType)
        varName = "p";
    int id = nextId();
    typeNames2typeIds.put(t.getErasedType().getQualifiedSourceName(), id);
    pb("Type " + varName + " = new Type();");
    pb(varName + ".name = \"" + t.getErasedType().getQualifiedSourceName() + "\";");
    pb(varName + ".id = " + id + ";");
    pb(varName + ".clazz = " + t.getErasedType().getQualifiedSourceName() + ".class;");
    if (t instanceof JClassType) {
        JClassType c = (JClassType) t;
        if (isVisible(c.getSuperclass()))
            pb(varName + ".superClass = " + c.getSuperclass().getErasedType().getQualifiedSourceName()
                    + ".class;");
        if (c.getFlattenedSupertypeHierarchy() != null) {
            pb("Set<Class> " + varName + "Assignables = new HashSet<Class>();");
            for (JType i : c.getFlattenedSupertypeHierarchy()) {
                if (!isVisible(i))
                    continue;
                pb(varName + "Assignables.add(" + i.getErasedType().getQualifiedSourceName() + ".class);");
            }
            pb(varName + ".assignables = " + varName + "Assignables;");
        }
        if (c.isInterface() != null)
            pb(varName + ".isInterface = true;");
        if (c.isEnum() != null)
            pb(varName + ".isEnum = true;");
        if (c.isArray() != null)
            pb(varName + ".isArray = true;");
        if (c.isMemberType())
            pb(varName + ".isMemberClass = true;");
        pb(varName + ".isStatic = " + c.isStatic() + ";");
        pb(varName + ".isAbstract = " + c.isAbstract() + ";");

        if (c.getFields() != null) {
            pb(varName + ".fields = new Field[] {");
            for (JField f : c.getFields()) {
                String enclosingType = getType(c);
                String fieldType = getType(f.getType());
                int setter = nextId();
                int getter = nextId();
                String elementType = getElementTypes(f);
                String annotations = getAnnotations(f.getDeclaredAnnotations());

                pb("new Field(\"" + f.getName() + "\", " + enclosingType + ", " + fieldType + ", " + f.isFinal()
                        + ", " + f.isDefaultAccess() + ", " + f.isPrivate() + ", " + f.isProtected() + ", "
                        + f.isPublic() + ", " + f.isStatic() + ", " + f.isTransient() + ", " + f.isVolatile()
                        + ", " + getter + ", " + setter + ", " + elementType + ", " + annotations + "), ");

                SetterGetterStub stub = new SetterGetterStub();
                stub.name = f.getName();
                stub.enclosingType = enclosingType;
                stub.type = fieldType;
                stub.isStatic = f.isStatic();
                stub.isFinal = f.isFinal();
                if (enclosingType != null && fieldType != null) {
                    stub.getter = getter;
                    stub.setter = setter;
                }
                setterGetterStubs.add(stub);
            }
            pb("};");
        }

        printMethods(c, varName, "Method", c.getMethods());
        if (c.isPublic() && !c.isAbstract() && (c.getEnclosingType() == null || c.isStatic())) {
            printMethods(c, varName, "Constructor", c.getConstructors());
        } else {
            logger.log(Type.INFO, c.getName() + " can't be instantiated. Constructors not generated");
        }

        if (c.isArray() != null) {
            pb(varName + ".componentType = " + getType(c.isArray().getComponentType()) + ";");
        }
        if (c.isEnum() != null) {
            JEnumConstant[] enumConstants = c.isEnum().getEnumConstants();
            if (enumConstants != null) {
                pb(varName + ".enumConstants = new Object[" + enumConstants.length + "];");
                for (int i = 0; i < enumConstants.length; i++) {
                    pb(varName + ".enumConstants[" + i + "] = " + c.getErasedType().getQualifiedSourceName()
                            + "." + enumConstants[i].getName() + ";");
                }
            }
        }

        Annotation[] annotations = c.getDeclaredAnnotations();
        if (annotations != null && annotations.length > 0) {
            pb(varName + ".annotations = " + getAnnotations(annotations) + ";");
        }
    } else if (t.isAnnotation() != null) {
        pb(varName + ".isAnnotation = true;");
    } else {
        pb(varName + ".isPrimitive = true;");
    }

    pb("types.put(\"" + t.getErasedType().getQualifiedSourceName() + "\", " + varName + ");");
    return buffer.toString();
}

From source file:com.artemis.gwtref.gen.ReflectionCacheSourceCreator.java

License:Apache License

private void printMethods(JClassType c, String varName, String methodType, JAbstractMethod[] methodTypes) {
    if (methodTypes != null) {
        pb(varName + "." + methodType.toLowerCase() + "s = new " + methodType + "[] {");
        for (JAbstractMethod m : methodTypes) {
            MethodStub stub = new MethodStub();
            stub.isPublic = m.isPublic();
            stub.enclosingType = getType(c);
            if (m.isMethod() != null) {
                stub.isMethod = true;/*from  w  w w. ja  v  a 2s  .co  m*/
                stub.returnType = getType(m.isMethod().getReturnType());
                stub.isStatic = m.isMethod().isStatic();
                stub.isAbstract = m.isMethod().isAbstract();
                stub.isNative = m.isMethod().isAbstract();
                stub.isFinal = m.isMethod().isFinal();

            } else {
                if (m.isPrivate() || m.isDefaultAccess()) {
                    logger.log(Type.INFO, "Skipping non-visible constructor for class " + c.getName());
                    continue;
                }
                if (m.getEnclosingType().isFinal() && !m.isPublic()) {
                    logger.log(Type.INFO, "Skipping non-public constructor for final class" + c.getName());
                    continue;
                }
                stub.isConstructor = true;
                stub.returnType = stub.enclosingType;
            }

            stub.jnsi = "";
            stub.methodId = nextId();
            stub.name = m.getName();
            methodStubs.add(stub);

            String methodAnnotations = getAnnotations(m.getDeclaredAnnotations());

            pb("new " + methodType + "(\"" + m.getName() + "\", ");
            pb(stub.enclosingType + ", ");
            pb(stub.returnType + ", ");

            pb("new Parameter[] {");
            if (m.getParameters() != null) {
                for (JParameter p : m.getParameters()) {
                    stub.parameterTypes.add(getType(p.getType()));
                    stub.jnsi += p.getType().getErasedType().getJNISignature();
                    pb("new Parameter(\"" + p.getName() + "\", " + getType(p.getType()) + ", \""
                            + p.getType().getJNISignature() + "\"), ");
                }
            }
            pb("}, ");

            pb(stub.isAbstract + ", " + stub.isFinal + ", " + stub.isStatic + ", " + m.isDefaultAccess() + ", "
                    + m.isPrivate() + ", " + m.isProtected() + ", " + m.isPublic() + ", " + stub.isNative + ", "
                    + m.isVarArgs() + ", " + stub.isMethod + ", " + stub.isConstructor + ", " + stub.methodId
                    + ", " + methodAnnotations + "),");
        }
        pb("};");
    }
}

From source file:com.badlogic.gwtref.gen.ReflectionCacheSourceCreator.java

License:Apache License

private String createTypeGenerator(JType t) {
    buffer.setLength(0);/*from   w  w  w.j  av  a2s . c  o m*/
    int id = nextTypeId++;
    typeNames2typeIds.put(t.getErasedType().getQualifiedSourceName(), id);
    JClassType c = t.isClass();

    String name = t.getErasedType().getQualifiedSourceName();
    String superClass = null;
    if (c != null && (isVisible(c.getSuperclass())))
        superClass = c.getSuperclass().getErasedType().getQualifiedSourceName() + ".class";
    String assignables = null;
    String interfaces = null;

    if (c != null && c.getFlattenedSupertypeHierarchy() != null) {
        assignables = "new HashSet<Class>(Arrays.asList(";
        boolean used = false;
        for (JType i : c.getFlattenedSupertypeHierarchy()) {
            if (!isVisible(i) || i.equals(t)
                    || "java.lang.Object".equals(i.getErasedType().getQualifiedSourceName()))
                continue;
            if (used)
                assignables += ", ";
            assignables += i.getErasedType().getQualifiedSourceName() + ".class";
            used = true;
        }
        if (used)
            assignables += "))";
        else
            assignables = null;
    }

    if (c == null) {
        // if it's not a class, it may be an interface instead
        c = t.isInterface();
    }

    if (c != null && c.getImplementedInterfaces() != null) {
        interfaces = "new HashSet<Class>(Arrays.asList(";
        boolean used = false;
        for (JType i : c.getImplementedInterfaces()) {
            if (!isVisible(i) || i.equals(t))
                continue;
            if (used)
                interfaces += ", ";
            interfaces += i.getErasedType().getQualifiedSourceName() + ".class";
            used = true;
        }
        if (used)
            interfaces += "))";
        else
            interfaces = null;
    }

    String varName = "c" + id;
    pb("private static Type " + varName + ";");
    pb("private static Type " + varName + "() {");
    pb("if(" + varName + "!=null) return " + varName + ";");
    pb(varName + " = new Type(\"" + name + "\", " + id + ", " + name + ".class, " + superClass + ", "
            + assignables + ", " + interfaces + ");");

    if (c != null) {
        if (c.isEnum() != null)
            pb(varName + ".isEnum = true;");
        if (c.isArray() != null)
            pb(varName + ".isArray = true;");
        if (c.isMemberType())
            pb(varName + ".isMemberClass = true;");
        if (c.isInterface() != null) {
            pb(varName + ".isInterface = true;");
        } else {
            pb(varName + ".isStatic = " + c.isStatic() + ";");
            pb(varName + ".isAbstract = " + c.isAbstract() + ";");
        }

        if (c.getFields() != null && c.getFields().length > 0) {
            pb(varName + ".fields = new Field[] {");
            for (JField f : c.getFields()) {
                String enclosingType = getType(c);
                String fieldType = getType(f.getType());
                int setterGetter = nextSetterGetterId++;
                String elementType = getElementTypes(f);
                String annotations = getAnnotations(f.getDeclaredAnnotations());

                pb("    new Field(\"" + f.getName() + "\", " + enclosingType + ", " + fieldType + ", "
                        + f.isFinal() + ", " + f.isDefaultAccess() + ", " + f.isPrivate() + ", "
                        + f.isProtected() + ", " + f.isPublic() + ", " + f.isStatic() + ", " + f.isTransient()
                        + ", " + f.isVolatile() + ", " + setterGetter + ", " + setterGetter + ", " + elementType
                        + ", " + annotations + "), ");

                SetterGetterStub stub = new SetterGetterStub();
                stub.name = f.getName();
                stub.enclosingType = enclosingType;
                stub.type = fieldType;
                stub.isStatic = f.isStatic();
                stub.isFinal = f.isFinal();
                if (enclosingType != null && fieldType != null) {
                    stub.getter = setterGetter;
                    stub.setter = setterGetter;
                }
                setterGetterStubs.add(stub);
            }
            pb("};");
        }

        createTypeInvokables(c, varName, "Method", c.getMethods());
        if (c.isPublic() && !c.isAbstract() && (c.getEnclosingType() == null || c.isStatic())) {
            createTypeInvokables(c, varName, "Constructor", c.getConstructors());
        } else {
            logger.log(Type.INFO, c.getName() + " can't be instantiated. Constructors not generated");
        }

        if (c.isArray() != null) {
            pb(varName + ".componentType = " + getType(c.isArray().getComponentType()) + ";");
        }
        if (c.isEnum() != null) {
            JEnumConstant[] enumConstants = c.isEnum().getEnumConstants();
            if (enumConstants != null) {
                pb(varName + ".enumConstants = new Object[" + enumConstants.length + "];");
                for (int i = 0; i < enumConstants.length; i++) {
                    pb(varName + ".enumConstants[" + i + "] = " + c.getErasedType().getQualifiedSourceName()
                            + "." + enumConstants[i].getName() + ";");
                }
            }
        }

        Annotation[] annotations = c.getDeclaredAnnotations();
        if (annotations != null && annotations.length > 0) {
            pb(varName + ".annotations = " + getAnnotations(annotations) + ";");
        }
    } else if (t.isAnnotation() != null) {
        pb(varName + ".isAnnotation = true;");
    } else {
        pb(varName + ".isPrimitive = true;");
    }

    pb("return " + varName + ";");
    pb("}");
    return buffer.toString();
}