org.robobinding.widgetaddon.DefaultViewAddOnFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of robobinding Show documentation
Show all versions of robobinding Show documentation
A Presentation Model(MVVM) framework for the Android platform
package org.robobinding.widgetaddon;
import java.lang.reflect.InvocationTargetException;
import org.robobinding.util.ConstructorUtils;
/**
* @since 1.0
* @author Cheng Wei
*
*/
public class DefaultViewAddOnFactory implements ViewAddOnFactory {
private final Class extends ViewAddOn> viewAddOnType;
public DefaultViewAddOnFactory(Class extends ViewAddOn> viewAddOnType) {
this.viewAddOnType = viewAddOnType;
}
@Override
public ViewAddOn create(Object view) {
try {
return ConstructorUtils.invokeConstructor(viewAddOnType, view);
} catch (NoSuchMethodException e) {
throw new RuntimeException("ViewAddOn class " + viewAddOnType.getName() + " does not have a constructor with a view parameter");
} catch (InvocationTargetException e) {
throw new RuntimeException(e);
} catch (InstantiationException e) {
throw new RuntimeException("ViewAddOn class " + viewAddOnType.getName() + " could not be instantiated: " + e);
} catch (IllegalAccessException e) {
throw new RuntimeException("ViewAddOn class " + viewAddOnType.getName() + " is not public");
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy