覆盖equals方法的注意事项

public abstract class AbstractPointcutAdvisor
{
@Override
	public boolean equals(Object other) {
		if (this == other) {
			return true;
		}
		if (!(other instanceof PointcutAdvisor)) {
			return false;
		}
		PointcutAdvisor otherAdvisor = (PointcutAdvisor) other;
		return (ObjectUtils.nullSafeEquals(getAdvice(), otherAdvisor.getAdvice()) &&
				ObjectUtils.nullSafeEquals(getPointcut(), otherAdvisor.getPointcut()));
	}

	@Override
	public int hashCode() {
		return PointcutAdvisor.class.hashCode();
	}
}


other instanceof PointcutAdvisor  要判断一下 类型,可能会有不是该类型的类传入

猜你喜欢

转载自wangqiaowqo.iteye.com/blog/1987774