use of org.robobinding.Bug in project RoboBinding by RoboBinding.
the class PresentationModelObjectLoader method load.
public AbstractPresentationModelObject load(Object presentationModel) {
if (presentationModel instanceof HasPresentationModelChangeSupport) {
Preconditions.checkNotNull(((HasPresentationModelChangeSupport) presentationModel).getPresentationModelChangeSupport(), "The PresentationModelChangeSupport from presentationModel.getPresentationModelChangeSupport() must not be null");
}
String presentationModelObjectClassName = getObjectClassName(presentationModel.getClass().getName());
Class<?> presentationModelObjectType;
try {
presentationModelObjectType = Class.forName(presentationModelObjectClassName);
} 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?", presentationModelObjectClassName));
}
try {
return (AbstractPresentationModelObject) ConstructorUtils.invokeConstructor(presentationModelObjectType, presentationModel);
} 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);
}
}
use of org.robobinding.Bug 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);
}
}
use of org.robobinding.Bug in project RoboBinding by RoboBinding.
the class LazyFunctions method find.
@Override
public Function find(String functionName, Class<?>... parameterTypes) {
Method method = MethodUtils.getMatchingAccessibleMethod(beanClass, functionName, parameterTypes);
if (method == null) {
return null;
}
MethodDescriptor methodDescriptor = new MethodDescriptor(method.getName(), method.getParameterTypes());
if (!functions.containsKey(methodDescriptor)) {
throw new RuntimeException("No such method '" + new MethodDescription(beanClass, method) + "'");
}
Function function = functions.get(methodDescriptor);
if (function == null) {
function = supply.tryToCreateFunction(methodDescriptor);
if (function == null) {
throw new Bug(MessageFormat.format("The method '{0}' is not generated", new MethodDescription(beanClass, method)));
}
functions.put(methodDescriptor, function);
}
return function;
}
Aggregations