mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
5066247: Refine the spec of equals() and hashCode() for j.text.Format classes
Reviewed-by: naoto, darcy
This commit is contained in:
parent
93f662f4fc
commit
8fcf70e931
9 changed files with 141 additions and 25 deletions
|
@ -2343,13 +2343,17 @@ public final class CompactNumberFormat extends NumberFormat {
|
|||
}
|
||||
|
||||
/**
|
||||
* Checks if this {@code CompactNumberFormat} is equal to the
|
||||
* specified {@code obj}. The objects of type {@code CompactNumberFormat}
|
||||
* are compared, other types return false; obeys the general contract of
|
||||
* {@link java.lang.Object#equals(java.lang.Object) Object.equals}.
|
||||
* Compares the specified object with this {@code CompactNumberFormat} for equality.
|
||||
* Returns true if the object is also a {@code CompactNumberFormat} and the
|
||||
* two formats would format any value the same.
|
||||
*
|
||||
* @implSpec This method performs an equality check with a notion of class
|
||||
* identity based on {@code getClass()}, rather than {@code instanceof}.
|
||||
* Therefore, in the equals methods in subclasses, no instance of this class
|
||||
* should compare as equal to an instance of a subclass.
|
||||
* @param obj the object to compare with
|
||||
* @return true if this is equal to the other {@code CompactNumberFormat}
|
||||
* @see Object#hashCode()
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
|
@ -2373,7 +2377,11 @@ public final class CompactNumberFormat extends NumberFormat {
|
|||
}
|
||||
|
||||
/**
|
||||
* {@return the hash code for this {@code CompactNumberFormat} instance}
|
||||
* {@return the hash code for this {@code CompactNumberFormat}}
|
||||
*
|
||||
* @implSpec Non-transient instance fields of this class are used to calculate
|
||||
* a hash code value which adheres to the contract defined in {@link Objects#hashCode}
|
||||
* @see Object#hashCode()
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue