ViewNavigationUtils.java 文件源码

java
阅读 36 收藏 0 点赞 0 评论 0

项目:holon-vaadin7 作者:
/**
 * Check given method has a valid signature for {@link OnShow} or {@link OnLeave} view method
 * @param viewClass View class
 * @param method Method to check
 * @param message Error message annotation description
 * @throws ViewConfigurationException Method is not valid
 */
private static void checkViewOnShowOrLeaveMethod(Class<?> viewClass, Method method, String message)
        throws ViewConfigurationException {
    if (method.getReturnType() != Void.class && method.getReturnType() != Void.TYPE) {
        throw new ViewConfigurationException("Invalid " + message + " method in view class " + viewClass.getName()
                + ": method must be a void return method");
    }
    int params = method.getParameterCount();
    if (params > 1) {
        throw new ViewConfigurationException("Invalid " + message + " method in view class " + viewClass.getName()
                + ": method must have no parameters or only one parameter of type ViewChangeEvent");
    }
    if (params == 1) {
        Parameter param = method.getParameters()[0];
        if (param.isVarArgs() || !(ViewChangeEvent.class.isAssignableFrom(param.getType())
                || ViewNavigatorChangeEvent.class.isAssignableFrom(param.getType()))) {
            throw new ViewConfigurationException(
                    "Invalid " + message + " method in view class " + viewClass.getName()
                            + ": method must have no parameters or only one parameter of type ViewChangeEvent");
        }
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号