Example usage for com.google.gwt.core.ext.typeinfo JConstructor getThrows

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

Introduction

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

Prototype

JClassType[] getThrows();

Source Link

Usage

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

License:Apache License

/**
 * Creates a mock GWT constructor for the given java constructor.
 *
 * @param realConstructor the java constructor
 * @param enclosingType the type to which the constructor belongs
 * @return the GWT constructor/*from  ww w.  j  a  v a 2 s .  co m*/
 */
private JConstructor adaptConstructor(final Constructor<?> realConstructor, JClassType enclosingType) {
    final JConstructor constructor = createMock(JConstructor.class);

    addCommonAbstractMethodBehaviour(realConstructor, constructor, enclosingType);
    addAnnotationBehaviour(realConstructor, constructor);

    // Parameters
    expect(constructor.getParameters()).andStubAnswer(new IAnswer<JParameter[]>() {
        public JParameter[] answer() throws Throwable {
            return adaptParameters(realConstructor.getParameterTypes(),
                    realConstructor.getParameterAnnotations(), constructor);
        }
    });

    // Thrown exceptions
    expect(constructor.getThrows()).andStubAnswer(new IAnswer<JClassType[]>() {
        public JClassType[] answer() throws Throwable {
            Class<?>[] realThrows = realConstructor.getExceptionTypes();
            JClassType[] gwtThrows = new JClassType[realThrows.length];
            for (int i = 0; i < realThrows.length; i++) {
                gwtThrows[i] = (JClassType) adaptType(realThrows[i]);
            }
            return gwtThrows;
        }
    });

    EasyMock.replay(constructor);
    return constructor;
}