nullargumentsnotallowedbeforeadvice.java
来自「一些很有用的spring的书籍」· Java 代码 · 共 24 行
JAVA
24 行
package com.apress.springbook.chapter03;
import org.springframework.aop.MethodBeforeAdvice;
import java.lang.reflect.Method;
public class NullArgumentsNotAllowedBeforeAdvice implements MethodBeforeAdvice {
public void before(Method method, Object[] arguments, Object target)
throws Throwable {
if (arguments == null || arguments.length == 0) {
return;
}
for (int i = 0; i < arguments.length; i++) {
Object argument = arguments[i];
if (argument == null) {
throw new IllegalArgumentException(
"Value for argument [" + i + "] is required but not present " +
"for method [" + method + "]!"
);
}
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?