mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8311188: Simplify and modernize equals and hashCode in java.text
Reviewed-by: lancea, naoto, rriggs
This commit is contained in:
parent
1fc726a8b3
commit
1dfb0fb3e2
15 changed files with 72 additions and 98 deletions
|
@ -47,6 +47,7 @@ import java.util.Arrays;
|
|||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -1132,6 +1133,7 @@ public class MessageFormat extends Format {
|
|||
/**
|
||||
* Equality comparison between two message format objects
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) // quick check
|
||||
return true;
|
||||
|
@ -1140,8 +1142,7 @@ public class MessageFormat extends Format {
|
|||
MessageFormat other = (MessageFormat) obj;
|
||||
return (maxOffset == other.maxOffset
|
||||
&& pattern.equals(other.pattern)
|
||||
&& ((locale != null && locale.equals(other.locale))
|
||||
|| (locale == null && other.locale == null))
|
||||
&& Objects.equals(locale,other.locale)
|
||||
&& Arrays.equals(offsets,other.offsets)
|
||||
&& Arrays.equals(argumentNumbers,other.argumentNumbers)
|
||||
&& Arrays.equals(formats,other.formats));
|
||||
|
@ -1150,6 +1151,7 @@ public class MessageFormat extends Format {
|
|||
/**
|
||||
* Generates a hash code for the message format object.
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return pattern.hashCode(); // enough for reasonable distribution
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue