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

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

Introduction

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

Prototype

JClassType[] getSubtypes();

Source Link

Usage

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   w w  w  .  j av  a  2s  .  c o  m

    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:com.github.ludorival.dao.gwt.rebind.EntityManagerGenerator.java

License:Apache License

private BeanMetadata create(GeneratorContext context, TreeLogger logger, String packageName, JClassType type,
        Class<?> classAdapter, IsEntity anno) throws TypeOracleException {
    String beanName = anno == null || anno.aliasName().isEmpty() ? type.getName() : anno.aliasName();
    Source implementation = null;
    JClassType implType = type;/*from   w  ww.j  av a2s . c  o m*/
    TypeOracle typeOracle = context.getTypeOracle();
    if (type.isInterface() != null) {
        implType = null;
        JClassType[] types = type.getSubtypes();
        log(logger, Type.DEBUG, "Get all sub types of %s : %s", type, Arrays.toString(types));
        if (types != null && types.length > 0) {
            for (JClassType jClassType : types) {
                if (isInstantiable(jClassType, logger)) {
                    implType = jClassType;
                    implementation = new Source(implType.getPackage().getName(), implType.getName());
                    break;
                }

            }

        }
        if (implType == null) {
            log(logger, Type.ERROR, "The type %s has not valid subtypes " + "%s !", type,
                    Arrays.toString(types));
            return null;
        }
    }
    if (!implType.isDefaultInstantiable())
        return null;
    String prefix = classAdapter.getSimpleName().replace("Adapter", "");
    boolean isEntity = anno != null;
    String className = prefix + beanName;
    if (parseOnlyInterface && implType != type)
        className += "Light";
    PrintWriter writer = context.tryCreate(logger, packageName, className);
    if (writer == null) {
        return new BeanMetadata(type, className, implementation, isEntity);
    }

    ClassSourceFileComposerFactory factory = new ClassSourceFileComposerFactory(packageName, className);
    logger.log(Type.DEBUG, "Create Entity " + factory.getCreatedClassName());

    factory.setSuperclass(classAdapter.getSimpleName() + "<" + type.getName() + ">");
    factory.addImport(RuntimeException.class.getName());
    factory.addImport(classAdapter.getName());
    factory.addImport(type.getQualifiedSourceName());
    if (isEntity) {
        factory.addImport(ArrayList.class.getName());
        factory.addImport(Collection.class.getName());
    }
    factory.addImport(HashMap.class.getName());
    factory.addImport(Property.class.getName());
    factory.addImport(Property.class.getName() + ".Kind");
    factory.addImport(Index.class.getName());
    factory.addImport(implType.getQualifiedSourceName());

    factory.addImport("javax.annotation.Generated");
    factory.addAnnotationDeclaration("@Generated(" + "value=\"" + AdapterEntity.class.getName() + "\", "
            + "date=\"" + new Date() + "\", " + "comments=\"Generated by DAO-GWT project.\")");

    SourceWriter sourceWriter = factory.createSourceWriter(context, writer);

    sourceWriter.println("//AUTO GENERATED FILE BY DAO-GWT " + getClass().getName() + ". DO NOT EDIT!\n");

    sourceWriter.println("private static HashMap<String,Property<%s,?>> PROPERTIES = "
            + "new HashMap<String,Property<%s,?>>();", type.getName(), type.getName());
    if (isEntity) {
        factory.addImport(ArrayList.class.getName());
        factory.addImport(Index.class.getName());
        sourceWriter.println("private static Collection<Index> INDEXES = " + "new ArrayList<Index>();");

    }
    sourceWriter.println("static {");
    sourceWriter.indent();
    JClassType interfaz = type != implType ? type : null;
    JMethod[] methods = parseOnlyInterface ? type.getInheritableMethods() : implType.getInheritableMethods();
    for (JMethod method : methods) {
        String name = method.getName();
        //Check if the method has a IsIgnored annotation before to continue
        IsIgnored ignored = method.getAnnotation(IsIgnored.class);
        if (ignored != null) {

            log(logger, Type.DEBUG, EXPLICITELY_IGNORED, name, implType);
            continue;
        }
        boolean startsWithGet = name.startsWith("get");
        boolean startsWithIs = name.startsWith("is");
        if (!startsWithGet && !startsWithIs) {
            log(logger, Type.DEBUG, IGNORE_METHOD, name, implType);
            continue;
        }

        //check no parameters
        if (method.getParameterTypes().length != 0) {
            log(logger, Type.WARN, NO_PARAMETER_GETTER, name, implType);
            continue;
        }
        //check return type
        JType returnType = method.getReturnType();
        if (returnType == null || returnType.getQualifiedSourceName().equals(Void.class.getName())
                || returnType.getQualifiedSourceName().equals(void.class.getName())) {
            log(logger, Type.DEBUG, VOID_GETTER, name + "" + returnType, implType);
            continue;
        }
        //change the format of the name getXyy ==> xyy
        String getterSetter = name;
        if (startsWithGet)
            getterSetter = name.substring(3);
        else if (startsWithIs)
            getterSetter = name.substring(2);
        name = getterSetter.substring(0, 1).toLowerCase() + getterSetter.substring(1);
        // check if the getter has an annotation
        IsIndexable indexable = method.getAnnotation(IsIndexable.class);
        boolean isIndexable = indexable != null;
        if (isIndexable && !isEntity)
            log(logger, Type.WARN, ONLY_ENTITY_FOR_INDEX, name, implType, IsEntity.class);

        isIndexable = isIndexable && isEntity;//only entity can defined indexable element

        String indexName = isIndexable ? indexable.aliasName() : "";
        String[] compositeIndexes = isIndexable ? indexable.compoundWith() : new String[0];
        Kind kind = null;
        JType typeOfCollection = null;
        String typeOfCollectionString = "null";

        if (!isPrimitive(returnType)) {

            //load complex properties except Key
            if (returnType.isEnum() != null) {
                kind = Kind.ENUM;
            } else {
                boolean isPrimitive = false;
                boolean isEnum = false;
                JParameterizedType pType = returnType.isParameterized();
                JType collection = typeOracle.parse(Collection.class.getName());

                if (pType != null && pType.getRawType().isAssignableTo(collection.isClassOrInterface())) {
                    JClassType[] types = pType.getTypeArgs();
                    kind = Kind.COLLECTION_OF_PRIMITIVES;
                    if (types.length > 1) {
                        log(logger, Type.DEBUG, CANNOT_PROCESS_PARAMETERIZED_TYPE, returnType, implType);
                        continue;
                    }
                    typeOfCollection = types[0];
                    typeOfCollectionString = typeOfCollection.getQualifiedSourceName() + ".class";
                    log(logger, Type.DEBUG, "The type of the collection is %s", typeOfCollectionString);
                    isPrimitive = isPrimitive(typeOfCollection);
                    isEnum = typeOfCollection.isEnum() != null;
                }
                if (!isPrimitive) {

                    if (isEnum && kind != null) {
                        kind = Kind.COLLECTION_OF_ENUMS;
                    } else {
                        JClassType classType = typeOfCollection != null ? typeOfCollection.isClassOrInterface()
                                : returnType.isClassOrInterface();
                        boolean isBean = isBean(classType);
                        if (isBean) {
                            log(logger, Type.DEBUG, "The property %s is well a type %s", name, classType);
                            if (kind == null)
                                kind = Kind.BEAN;
                            else
                                kind = Kind.COLLECTION_OF_BEANS;
                        } else {
                            log(logger, Type.DEBUG, "The property %s has not a bean type %s", name, classType);
                            continue;
                        }
                    }

                }
            }

        }
        assert kind != null;

        boolean isMemo = method.getAnnotation(IsMemo.class) != null;
        String oldName = "null";
        OldName oldNameAnno = method.getAnnotation(OldName.class);
        if (oldNameAnno != null)
            oldName = "\"" + oldNameAnno.value() + "\"";
        //create a property
        if (kind == Kind.BEAN || kind == Kind.COLLECTION_OF_BEANS)
            factory.addImport(returnType.getQualifiedSourceName());
        String valueType = "";
        JClassType classType = returnType.isClassOrInterface();
        JPrimitiveType primitiveType = returnType.isPrimitive();
        if (classType != null)
            valueType = classType.getQualifiedSourceName();
        else if (primitiveType != null) {
            valueType = primitiveType.getQualifiedBoxedSourceName();
        }

        sourceWriter.println("{ //Property %s", name);
        sourceWriter.indent();
        sourceWriter.print("Index index =");
        if (isIndexable) {
            if (indexName.isEmpty())
                indexName = name;
            sourceWriter.println("new Index(\"%s\",\"%s\",new String[]{%s});", indexName, name,
                    String.join(",", compositeIndexes));
        } else
            sourceWriter.println("null;");
        boolean useKeyAsString = anno != null ? (name.equals(anno.keyName()) ? anno.useKeyAsString() : false)
                : false;

        KeyOf keyOf = method.getAnnotation(KeyOf.class);
        if (keyOf != null) {
            IsEntity isEntity2 = keyOf.entity().getAnnotation(IsEntity.class);
            if (isEntity2 == null) {
                log(logger, Type.ERROR, AdapterEntityManager.KEY_OF_NO_ENTITY, method, keyOf, keyOf.entity(),
                        IsEntity.class);
                continue;
            }
            useKeyAsString = isEntity2.useKeyAsString();
        }
        boolean isHidden = isHidden(method, interfaz);
        sourceWriter.println(
                "Property<%s,%s> property = new Property<%s,%s>(\"%s\",%s,%s.class,%s,%s,%s,%s,index,%s){",
                type.getName(), valueType, type.getName(), valueType, name, oldName,
                returnType.getQualifiedSourceName(), typeOfCollectionString,
                kind != null ? "Kind." + kind.name() : "null", useKeyAsString + "", isMemo + "", isHidden + "");
        sourceWriter.indent();
        sourceWriter.println("@Override");
        sourceWriter.println("public %s get(%s instance){", valueType, type.getName());
        sourceWriter.indent();

        sourceWriter.println("return ((%s)instance).%s();", implType.getName(),
                startsWithGet ? "get" + getterSetter : "is" + getterSetter);
        sourceWriter.outdent();
        sourceWriter.println("}");

        sourceWriter.println("@Override");
        sourceWriter.println("public void set(%s instance, %s value){", type.getName(), valueType);
        sourceWriter.indent();

        if (getSetter(implType, getterSetter, returnType) != null)
            sourceWriter.println("((%s)instance).%s(value);", implType.getName(), "set" + getterSetter);
        else {
            logger.log(Type.WARN, " Not found setter for " + getterSetter);
            sourceWriter.println("throw new RuntimeException(\"No such setter " + getterSetter + " \");");
        }

        sourceWriter.outdent();
        sourceWriter.println("}");
        sourceWriter.outdent();
        sourceWriter.println("};");
        sourceWriter.println("PROPERTIES.put(\"%s\",property);", name);
        if (!oldName.equals("null")) {
            sourceWriter.println("PROPERTIES.put(%s,property);", oldName);
        }
        if (isIndexable)
            sourceWriter.println("INDEXES.add(index);");
        sourceWriter.outdent();
        sourceWriter.println("}");

        log(logger, Type.DEBUG, SUCCESSFUL_ADD_PROPERTY, name + ":" + valueType, implType);

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

    sourceWriter.println();
    sourceWriter.println("public %s(){", className);
    sourceWriter.indent();

    /*
     * boolean asyncReady,
       boolean autoGeneratedFlag,
       String keyName,
       boolean useKeyAsString,
       Class<T> type,Class<? extends T> implType,
       Map<String, Property<T,?>> mapAllProperties, Collection<Index> indexes) {
    super(type,implType,mapAllProperties);
     */
    if (isEntity)
        sourceWriter
                .println(String.format("super(\"%s\",%s,%s,\"%s\",%s,%s.class,%s.class,PROPERTIES,INDEXES);",
                        anno.aliasName().isEmpty() ? type.getName() : anno.aliasName(), anno.asyncReady(),
                        anno.autoGeneratedKey(), anno.keyName(), anno.useKeyAsString(), type.getName(),
                        implType.getName()));
    else {
        sourceWriter.println(
                String.format("super(%s.class,%s.class,PROPERTIES);", type.getName(), implType.getName()));

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

    sourceWriter.println();
    sourceWriter.println("@Override");
    sourceWriter.println("public %s newInstance(){", type.getName());
    sourceWriter.indent();
    sourceWriter.println("return new %s();", implType.getName());
    sourceWriter.outdent();
    sourceWriter.println("}");

    sourceWriter.outdent();
    sourceWriter.println("}");
    context.commit(logger, writer);

    return new BeanMetadata(type, className, implementation, isEntity);
}

From source file:com.github.nmorel.gwtjackson.rebind.CreatorUtils.java

License:Apache License

public static ImmutableList<JClassType> filterSubtypesForSerialization(TreeLogger logger,
        RebindConfiguration configuration, JClassType type) {
    boolean filterOnlySupportedType = isObjectOrSerializable(type);

    ImmutableList.Builder<JClassType> builder = ImmutableList.builder();
    if (type.getSubtypes().length > 0) {
        for (JClassType subtype : type.getSubtypes()) {
            if (null == subtype.isAnnotation() && subtype.isPublic()
                    && (!filterOnlySupportedType
                            || configuration.isTypeSupportedForSerialization(logger, subtype))
                    && !findFirstEncounteredAnnotationsOnAllHierarchy(configuration,
                            subtype.isClassOrInterface(), JsonIgnoreType.class, Optional.of(type))
                                    .isPresent()) {
                builder.add(subtype);/* w ww  .j  av  a  2  s .  c  o  m*/
            }
        }
    }
    return builder.build();
}

From source file:com.github.nmorel.gwtjackson.rebind.CreatorUtils.java

License:Apache License

public static ImmutableList<JClassType> filterSubtypesForDeserialization(TreeLogger logger,
        RebindConfiguration configuration, JClassType type) {
    boolean filterOnlySupportedType = isObjectOrSerializable(type);

    ImmutableList.Builder<JClassType> builder = ImmutableList.builder();
    if (type.getSubtypes().length > 0) {
        for (JClassType subtype : type.getSubtypes()) {
            if ((null == subtype.isInterface() && !subtype.isAbstract()
                    && (!subtype.isMemberType() || subtype.isStatic())) && null == subtype.isAnnotation()
                    && subtype.isPublic()
                    && (!filterOnlySupportedType || (configuration.isTypeSupportedForDeserialization(logger,
                            subtype)//from   ww w.  j  a v a 2 s . co m
                            // EnumSet and EnumMap are not supported in subtype deserialization because we can't know the enum to use.
                            && !EnumSet.class.getCanonicalName().equals(subtype.getQualifiedSourceName())
                            && !EnumMap.class.getCanonicalName().equals(subtype.getQualifiedSourceName())))
                    && !findFirstEncounteredAnnotationsOnAllHierarchy(configuration,
                            subtype.isClassOrInterface(), JsonIgnoreType.class, Optional.of(type))
                                    .isPresent()) {
                builder.add(subtype);
            }
        }
    }
    return builder.build();
}

From source file:com.github.nmorel.gwtjackson.rebind.RebindConfiguration.java

License:Apache License

/**
 * Adds to {@link #mixInAnnotations} the configured mix-in annotations passed in parameters
 *
 * @param mapMixInAnnotations mix-ins annotations to add
 * @param mapperMixIns Annotation defined on mapper
 *///from   w  w w.j  a va  2s. co m
private void addMixInAnnotations(Map<Class, Class> mapMixInAnnotations, JsonMixIns mapperMixIns) {
    if (null != mapperMixIns) {
        for (JsonMixIn jsonMixIn : mapperMixIns.value()) {
            JClassType targetType = findClassType(jsonMixIn.target());
            if (null == targetType) {
                continue;
            }
            specificTypes.add(targetType);
            specificTypes.addAll(Arrays.asList(targetType.getSubtypes()));

            mapMixInAnnotations.put(jsonMixIn.target(), jsonMixIn.mixIn());
        }
    }

    if (!mapMixInAnnotations.isEmpty()) {
        for (Entry<Class, Class> entry : mapMixInAnnotations.entrySet()) {
            JClassType targetType = findClassType(entry.getKey());
            if (null == targetType) {
                continue;
            }

            JClassType mixInType = findClassType(entry.getValue());
            if (null == mixInType) {
                continue;
            }

            mixInAnnotations.put(targetType.getQualifiedSourceName(), mixInType);
        }
    }
}

From source file:com.google.gwt.sample.showcase.generator.ShowcaseGenerator.java

License:Apache License

@Override
public String generate(TreeLogger logger, GeneratorContext context, String typeName)
        throws UnableToCompleteException {
    this.logger = logger;
    this.context = context;
    this.classLoader = Thread.currentThread().getContextClassLoader();

    // Only generate files on the first permutation
    if (!isFirstPass()) {
        return null;
    }/* w w w .j av  a  2s  . c  o  m*/

    // Get the Showcase ContentWidget subtypes to examine
    JClassType cwType = null;
    try {
        cwType = context.getTypeOracle().getType(ContentWidget.class.getName());
    } catch (NotFoundException e) {
        logger.log(TreeLogger.ERROR, "Cannot find ContentWidget class", e);
        throw new UnableToCompleteException();
    }
    JClassType[] types = cwType.getSubtypes();

    // Generate the source and raw source files
    for (JClassType type : types) {
        generateRawFiles(type);
        generateSourceFiles(type);
    }

    // Generate the CSS source files
    String[] themes = new String[] { Showcase.THEME };
    for (String theme : themes) {
        String styleDefsLTR = getStyleDefinitions(theme, false);
        String styleDefsRTL = getStyleDefinitions(theme, true);
        String outDirLTR = ShowcaseConstants.DST_SOURCE_STYLE + theme + "/";
        String outDirRTL = ShowcaseConstants.DST_SOURCE_STYLE + theme + "_rtl/";
        for (JClassType type : types) {
            generateStyleFiles(type, styleDefsLTR, outDirLTR);
            generateStyleFiles(type, styleDefsRTL, outDirRTL);
        }
    }

    return null;
}

From source file:com.googlecode.gflot.examples.generator.SourceGenerator.java

License:Apache License

@Override
public String generate(TreeLogger logger, GeneratorContext context, String typeName)
        throws UnableToCompleteException {
    this.logger = logger;
    this.context = context;
    this.classLoader = Thread.currentThread().getContextClassLoader();

    // Only generate files on the first permutation
    if (!isFirstPass()) {
        return null;
    }//from   w  w  w  . j ava2 s . c  o  m

    // Get the ContentActivity subtypes to examine
    JClassType cwType = null;
    try {
        cwType = context.getTypeOracle().getType(DefaultActivity.class.getName());
    } catch (NotFoundException e) {
        logger.log(TreeLogger.ERROR, "Cannot find ContentActivity class", e);
        throw new UnableToCompleteException();
    }
    JClassType[] types = cwType.getSubtypes();

    // Generate the source and raw source files
    for (JClassType type : types) {
        generateRawFiles(type);
        generateSourceFiles(type);
    }

    return null;
}

From source file:com.gwtent.gen.reflection.ReflectAllInOneCreator.java

License:Apache License

private void getAllReflectionClasses() throws NotFoundException {

    //System annotations
    addClassIfNotExists(typeOracle.getType(Retention.class.getCanonicalName()),
            ReflectableHelper.getDefaultSettings(typeOracle));
    addClassIfNotExists(typeOracle.getType(Documented.class.getCanonicalName()),
            ReflectableHelper.getDefaultSettings(typeOracle));
    addClassIfNotExists(typeOracle.getType(Inherited.class.getCanonicalName()),
            ReflectableHelper.getDefaultSettings(typeOracle));
    addClassIfNotExists(typeOracle.getType(Target.class.getCanonicalName()),
            ReflectableHelper.getDefaultSettings(typeOracle));
    addClassIfNotExists(typeOracle.getType(Deprecated.class.getCanonicalName()),
            ReflectableHelper.getDefaultSettings(typeOracle));
    //typeOracle.getType("com.gwtent.client.test.reflection.TestReflectionGenerics.TestReflection1");

    //=====GWT0.7
    for (JClassType classType : typeOracle.getTypes()) {
        Reflectable reflectable = GenUtils.getClassTypeAnnotationWithMataAnnotation(classType,
                Reflectable.class);
        if (reflectable != null) {
            processClass(classType, reflectable);

            if (reflectable.assignableClasses()) {
                for (JClassType type : classType.getSubtypes()) {
                    processClass(type, reflectable);
                }/*from  w w w  .j  ava 2  s .co  m*/
            }
        }
    }
    //======end of gwt0.7
}

From source file:com.gwtent.showcase.generator.ShowcaseGenerator.java

License:Apache License

@Override
public String generate(TreeLogger logger, GeneratorContext context, String typeName)
        throws UnableToCompleteException {
    this.logger = logger;
    this.context = context;
    this.classLoader = getClass().getClassLoader();

    // Only generate files on the first permutation
    if (!isFirstPass()) {
        return null;
    }/*  w ww  .  ja v a 2  s  .c  o  m*/

    // Get the Showcase ContentWidget subtypes to examine
    JClassType cwType = null;
    try {
        cwType = context.getTypeOracle().getType(ContentWidget.class.getName());
    } catch (NotFoundException e) {
        logger.log(TreeLogger.ERROR, "Cannot find ContentWidget class", e);
        throw new UnableToCompleteException();
    }
    JClassType[] types = cwType.getSubtypes();

    // Generate the source and raw source files
    for (JClassType type : types) {
        generateRawFiles(type);
        generateSourceFiles(type);
    }

    // Generate the CSS source files
    for (String theme : ShowcaseConstants.STYLE_THEMES) {
        String styleDefsLTR = getStyleDefinitions(theme, false);
        String styleDefsRTL = getStyleDefinitions(theme, true);
        String outDirLTR = ShowcaseConstants.DST_SOURCE_STYLE + theme + "/";
        String outDirRTL = ShowcaseConstants.DST_SOURCE_STYLE + theme + "_rtl/";
        for (JClassType type : types) {
            generateStyleFiles(type, styleDefsLTR, outDirLTR);
            generateStyleFiles(type, styleDefsRTL, outDirRTL);
        }
    }

    return null;
}

From source file:com.kk_electronic.gwt.rebind.FlexInjectorGenerator.java

License:Open Source License

private Map<String, Vector<JClassType>> getClasses() throws UnableToCompleteException {
    if (this.groups != null) {
        return this.groups;
    }//  w  ww .j  a v  a2 s .c  o  m

    this.groups = new HashMap<String, Vector<JClassType>>();

    try {
        typeOracle.getType(ConstructFromLiteral.class.getCanonicalName());
    } catch (NotFoundException error) {
        logger.log(TreeLogger.ERROR, "Can't find marker interface", error);
        throw new UnableToCompleteException();
    }

    for (JClassType j : typeOracle.getTypes()) {
        ConstructFromLiteral a = j.getAnnotation(ConstructFromLiteral.class);
        if (a != null) {
            if (a.includeConcreteClasses() && (j.isClass() != null && !j.isAbstract())) {
                addClass(j);
            }
            if (a.includeInterfaces() && (j.isInterface() != null)) {
                addClass(j);
            }
            if (a.recursive()) {
                for (JClassType e : j.getSubtypes()) {
                    if (a.includeConcreteClasses() && (e.isClass() != null && !e.isAbstract())) {
                        addClass(e);
                    }
                    if (a.includeInterfaces() && (e.isInterface() != null)) {
                        addClass(e);
                    }
                }
            }
        }
    }
    return groups;
}