Search in sources :

Example 1 with ViewBinding

use of org.robobinding.viewbinding.ViewBinding in project RoboBinding by RoboBinding.

the class ViewBindingLoader method load.

@SuppressWarnings("unchecked")
public <ViewType> ViewBinding<ViewType> load(CustomViewBinding<ViewType> customViewBinding) {
    String viewBindingClassName = getViewBindingClassName(customViewBinding.getClass().getName());
    Class<?> viewBindingType;
    try {
        viewBindingType = Class.forName(viewBindingClassName);
    } catch (ClassNotFoundException e) {
        throw new RuntimeException(MessageFormat.format("The source code for ''{0}'' is not generated. Is Java annotation processing(source code generation) correctly configured?", viewBindingClassName));
    }
    try {
        return (ViewBinding<ViewType>) ConstructorUtils.invokeConstructor(viewBindingType, customViewBinding);
    } catch (NoSuchMethodException e) {
        throw new Bug("This is a bug of constructor code generation", e);
    } catch (IllegalAccessException e) {
        throw new Bug("This is a bug of constructor code generation", e);
    } catch (InvocationTargetException e) {
        throw new Bug("This is a bug of constructor code generation", e);
    } catch (InstantiationException e) {
        throw new Bug("This is a bug of constructor code generation", e);
    }
}
Also used : ViewBinding(org.robobinding.viewbinding.ViewBinding) Bug(org.robobinding.Bug) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Bug (org.robobinding.Bug)1 ViewBinding (org.robobinding.viewbinding.ViewBinding)1