Example usage for com.google.gwt.core.ext.typeinfo NotFoundException NotFoundException

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

Introduction

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

Prototype

public NotFoundException() 

Source Link

Usage

From source file:org.jrydberg.bindings.rebind.DataBindingGenerator.java

License:Apache License

private void findImplClasses(TypeOracle typeOracle, JClassType type, Map<JClassType, JClassType> classes)
        throws NotFoundException {

    JClassType[] interfaces = type.getImplementedInterfaces();
    if (interfaces.length != 1) {
        throw new NotFoundException();
    }// w  w w  .  ja  v  a2s.c o  m

    JParameterizedType isParameterized = interfaces[0].isParameterized();
    if (isParameterized == null) {
        // logger.warn(
        // "The method 'getAssociatedType()' in '%s' does not return Type<? extends EventHandler>.",
        // eventType.getName());
        // return null;
    }

    JClassType[] argTypes = isParameterized.getTypeArgs();
    if ((argTypes.length != 1)) {
        // logger.warn(
        // "The method 'getAssociatedType()' in '%s' does not return Type<? extends EventHandler>.",
        // eventType.getName());
        // return null;
    }
    classes.put(type, argTypes[0]);

    // JClassType superClass = type.getSuperclass();

    // JGenericType genericType = superClass.isGenericType();
    // JTypeParameter[] typeParameters = genericType.getTypeParameters();
    // classes.put(type, typeParameters[0]);

    JClassType dataBindingClass = typeOracle.getType(DataBinding.class.getName());

    JMethod[] methods = type.getOverridableMethods();
    for (JMethod method : methods) {
        if (!method.isPublic() || method.isStatic()) {
            continue;
        }

        JType propertyType = method.getReturnType().getErasedType();
        assert propertyType != null;

        JClassType possibleImplClass = propertyType.isInterface();
        if (possibleImplClass != null) {
            if (possibleImplClass.isAssignableTo(dataBindingClass)) {
                if (!classes.containsKey(possibleImplClass))
                    findImplClasses(typeOracle, possibleImplClass, classes);
            }
        }
    }
}

From source file:org.opencms.gwt.rebind.CmsClassInitGenerator.java

License:Open Source License

/**
 * @see com.google.gwt.core.ext.Generator#generate(com.google.gwt.core.ext.TreeLogger, com.google.gwt.core.ext.GeneratorContext, java.lang.String)
 *///w w w. ja  v  a2 s.c  om
@Override
public String generate(TreeLogger logger, GeneratorContext context, String typeName)
        throws UnableToCompleteException {

    TypeOracle oracle = context.getTypeOracle();
    JClassType initClass = oracle.findType(MARKER_INTERFACE_NAME);
    List<JClassType> initTypes = new ArrayList<JClassType>();
    for (JClassType subtype : initClass.getSubtypes()) {
        try {
            JMethod method = subtype.getMethod("initClass", new JType[] {});
            if (!method.isStatic()) {
                throw new NotFoundException();
            }
            initTypes.add(subtype);
        } catch (NotFoundException e) {
            logger.log(TreeLogger.ERROR,
                    "Could not find initClass() method in class " + subtype.getQualifiedSourceName());
            throw new UnableToCompleteException();
        }
    }
    generateClass(logger, context, initTypes);
    return PACKAGE_NAME + "." + CLASS_NAME;
}

From source file:org.opencms.gwt.rebind.CmsCommandInitGenerator.java

License:Open Source License

/**
 * @see com.google.gwt.core.ext.Generator#generate(com.google.gwt.core.ext.TreeLogger, com.google.gwt.core.ext.GeneratorContext, java.lang.String)
 *//* ww w .  j a v  a2 s .c  o  m*/
@Override
public String generate(TreeLogger logger, GeneratorContext context, String typeName)
        throws UnableToCompleteException {

    TypeOracle oracle = context.getTypeOracle();
    JClassType initClass = oracle.findType(MARKER_INTERFACE_NAME);
    List<JClassType> initTypes = new ArrayList<JClassType>();
    for (JClassType subtype : initClass.getSubtypes()) {
        try {
            JMethod method = subtype.getMethod(GET_COMMAND_METHOD, new JType[] {});
            if (!method.isStatic()) {
                throw new NotFoundException();
            }
            initTypes.add(subtype);
        } catch (NotFoundException e) {
            logger.log(TreeLogger.ERROR, "Could not find " + GET_COMMAND_METHOD + "() method in class "
                    + subtype.getQualifiedSourceName());
            throw new UnableToCompleteException();
        }
    }
    generateClass(logger, context, initTypes);
    return PACKAGE_NAME + "." + CLASS_NAME;
}