我有一个接受 DTO 并返回一些结果的服务:
@Override
public int foo(Bar bar) {
....
}
条形如下(简化):
public class Bar {
public int id;
public String name;
public String baz;
@Override
public int hashCode() {
//this is already being defined for something else
...
}
@Override
public boolean equals(Object o) {
//this is already being defined for something else
...
}
}
我想在 foo 方法上使用 @Cacheable;但是,我想对 id 和 name 属性进行哈希处理,而不是 baz。有没有办法做到这一点?