com.gitee.l0km.aocache.InvokeKey Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aocache Show documentation
Show all versions of aocache Show documentation
call/execution caching utility based on aspectj
package com.gitee.l0km.aocache;
import java.util.Arrays;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicLong;
import org.aspectj.lang.ProceedingJoinPoint;
class InvokeKey implements AocacheConstant{
final Object target;
final Object[] args;
/**
* 切入点对象,不参与hash,equals
*/
final ProceedingJoinPoint joinPoint;
/**
* 调用计数器,不参与hash,equals
*/
final AtomicLong invokedCounter = new AtomicLong();
InvokeKey(ProceedingJoinPoint joinPoint) {
this.target = joinPoint.getTarget();
this.args = joinPoint.getArgs();
this.joinPoint = joinPoint;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + Arrays.deepHashCode(args);
result = prime * result + Objects.hash(target);
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
InvokeKey other = (InvokeKey) obj;
return Arrays.deepEquals(args, other.args) && Objects.equals(target, other.target);
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("InvokeKey [target=").append(target).append(", args=").append(Arrays.toString(args))
.append(", invokedCounter=").append(invokedCounter).append("]");
return builder.toString();
}
public String toSimpleString() {
StringBuilder builder = new StringBuilder();
builder.append("[target=").append(target).append(", args=").append(Arrays.toString(args))
.append("]");
return builder.toString();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy