📄 objectmethodcall.java
字号:
/**
*
*/
package quickstart.cache;
import java.lang.reflect.Method;
import java.util.Arrays;
/**
* @author tamdv
*
*/
public class ObjectMethodCall {
private int hashCode = 0;
final Object target;
final Method method;
final Object[] args;
public ObjectMethodCall(final Object target, final Method method,
final Object[] args) {
this.target = target;
this.method = method;
this.args = args;
}
@Override
public int hashCode() {
if (hashCode == 0) {
hashCode = 7 + target.hashCode();
hashCode = 31 * hashCode + method.hashCode();
hashCode = 31 * hashCode + Arrays.hashCode(args);
if (hashCode == 0) {
hashCode = 1;
}
}
return hashCode;
}
@Override
public boolean equals(Object object) {
if (!(object instanceof ObjectMethodCall)) {
return false;
}
final ObjectMethodCall methodCall = (ObjectMethodCall) object;
if ((!methodCall.target.equals(target))
|| (!methodCall.method.equals(method))) {
return false;
}
return Arrays.equals(methodCall.args, args);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -