Example usage for com.google.gwt.core.ext.typeinfo JTypeParameter getBounds

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

Introduction

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

Prototype

JClassType[] getBounds();

Source Link

Usage

From source file:fr.onevu.gwt.uibinder.rebind.UiBinderWriter.java

License:Apache License

public boolean isElementAssignableTo(XMLElement elem, JClassType possibleSupertype)
        throws UnableToCompleteException {
    /*/*  w  ww .  j  a  va 2s  .  co  m*/
     * Things like <W extends IsWidget & IsPlaid>
     */
    JTypeParameter typeParameter = possibleSupertype.isTypeParameter();
    if (typeParameter != null) {
        JClassType[] bounds = typeParameter.getBounds();
        for (JClassType bound : bounds) {
            if (!isElementAssignableTo(elem, bound)) {
                return false;
            }
        }
        return true;
    }

    /*
     * Binder fields are always declared raw, so we're cheating if the user is
     * playing with parameterized types. We're happy enough if the raw types
     * match, and rely on them to make sure the specific types really do work.
     */
    JParameterizedType parameterized = possibleSupertype.isParameterized();
    if (parameterized != null) {
        return isElementAssignableTo(elem, parameterized.getRawType());
    }

    JClassType fieldtype = findFieldType(elem);
    if (fieldtype == null) {
        return false;
    }
    return fieldtype.isAssignableTo(possibleSupertype);
}