@@ -75,11 +75,6 @@ public class ExtendedMessageFormat extends MessageFormat {
7575 */
7676 private static final long serialVersionUID = -2362048321261811743L ;
7777
78- /**
79- * Our initial seed value for calculating hashes.
80- */
81- private static final int HASH_SEED = 31 ;
82-
8378 /**
8479 * The empty string.
8580 */
@@ -292,31 +287,19 @@ private boolean containsElements(final Collection<?> coll) {
292287 return coll .stream ().anyMatch (Objects ::nonNull );
293288 }
294289
295- /**
296- * Tests if this extended message format is equal to another object.
297- *
298- * @param obj the object to compare to
299- * @return true if this object equals the other, otherwise false
300- */
301290 @ Override
302291 public boolean equals (final Object obj ) {
303- if (obj == this ) {
292+ if (this == obj ) {
304293 return true ;
305294 }
306- if (obj == null ) {
307- return false ;
308- }
309- if (!Objects .equals (getClass (), obj .getClass ())) {
310- return false ;
311- }
312- final ExtendedMessageFormat rhs = (ExtendedMessageFormat ) obj ;
313- if (!Objects .equals (toPattern , rhs .toPattern )) {
295+ if (!super .equals (obj )) {
314296 return false ;
315297 }
316- if (!super . equals (obj )) {
298+ if (!(obj instanceof ExtendedMessageFormat )) {
317299 return false ;
318300 }
319- return Objects .equals (registry , rhs .registry );
301+ final ExtendedMessageFormat other = (ExtendedMessageFormat ) obj ;
302+ return Objects .equals (registry , other .registry ) && Objects .equals (toPattern , other .toPattern );
320303 }
321304
322305 /**
@@ -352,14 +335,11 @@ private void getQuotedString(final String pattern, final ParsePosition pos) {
352335 appendQuotedString (pattern , pos , null );
353336 }
354337
355- /**
356- * {@inheritDoc}
357- */
358338 @ Override
359339 public int hashCode () {
360- int result = super . hashCode () ;
361- result = HASH_SEED * result + Objects .hashCode (registry );
362- return HASH_SEED * result + Objects .hashCode ( toPattern );
340+ final int prime = 31 ;
341+ final int result = super .hashCode ();
342+ return prime * result + Objects .hash ( registry , toPattern );
363343 }
364344
365345 /**
0 commit comments