8311188: Simplify and modernize equals and hashCode in java.text

Reviewed-by: lancea, naoto, rriggs
This commit is contained in:
Pavel Rappo 2023-07-18 15:12:09 +00:00
parent 1fc726a8b3
commit 1dfb0fb3e2
15 changed files with 72 additions and 98 deletions

View file

@ -729,9 +729,9 @@ public class RuleBasedCollator extends Collator{
* @return true if the current table-based collation object is the same
* as the table-based collation object obj; false otherwise.
*/
@Override
public boolean equals(Object obj) {
if (obj == null) return false;
if (!super.equals(obj)) return false; // super does class check
if (!super.equals(obj)) return false; // super does null and class checks
RuleBasedCollator other = (RuleBasedCollator) obj;
// all other non-transient information is also contained in rules.
return (getRules().equals(other.getRules()));
@ -740,6 +740,7 @@ public class RuleBasedCollator extends Collator{
/**
* Generates the hash code for the table-based collation object
*/
@Override
public int hashCode() {
return getRules().hashCode();
}