Consistent equals/hashCode style (and related polishing)

This commit is contained in:
Juergen Hoeller
2023-07-19 00:35:19 +02:00
parent bbcc788f60
commit 2f33e77ab4
98 changed files with 413 additions and 835 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -82,16 +82,11 @@ public class TypedValue {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof TypedValue otherTv)) {
return false;
}
// Avoid TypeDescriptor initialization if not necessary
return (ObjectUtils.nullSafeEquals(this.value, otherTv.value) &&
((this.typeDescriptor == null && otherTv.typeDescriptor == null) ||
ObjectUtils.nullSafeEquals(getTypeDescriptor(), otherTv.getTypeDescriptor())));
return (this == other || (other instanceof TypedValue that &&
ObjectUtils.nullSafeEquals(this.value, that.value) &&
((this.typeDescriptor == null && that.typeDescriptor == null) ||
ObjectUtils.nullSafeEquals(getTypeDescriptor(), that.getTypeDescriptor()))));
}
@Override

View File

@@ -591,14 +591,9 @@ public class ReflectivePropertyAccessor implements PropertyAccessor {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof PropertyCacheKey otherKey)) {
return false;
}
return (this.clazz == otherKey.clazz && this.property.equals(otherKey.property) &&
this.targetIsClass == otherKey.targetIsClass);
return (this == other || (other instanceof PropertyCacheKey that &&
this.clazz == that.clazz && this.property.equals(that.property) &&
this.targetIsClass == that.targetIsClass));
}
@Override