Consistent equals implementations across class hierarchies
Issue: SPR-13951
(cherry picked from commit ac44f9e)
			
			
This commit is contained in:
		
							parent
							
								
									08f2ab942c
								
							
						
					
					
						commit
						659e44146c
					
				|  | @ -1,5 +1,5 @@ | ||||||
| /* | /* | ||||||
|  * Copyright 2002-2012 the original author or authors. |  * Copyright 2002-2016 the original author or authors. | ||||||
|  * |  * | ||||||
|  * Licensed under the Apache License, Version 2.0 (the "License"); |  * Licensed under the Apache License, Version 2.0 (the "License"); | ||||||
|  * you may not use this file except in compliance with the License. |  * you may not use this file except in compliance with the License. | ||||||
|  | @ -106,7 +106,7 @@ public class DefaultMessageSourceResolvable implements MessageSourceResolvable, | ||||||
| 	 * the last one in the codes array. | 	 * the last one in the codes array. | ||||||
| 	 */ | 	 */ | ||||||
| 	public String getCode() { | 	public String getCode() { | ||||||
| 		return (this.codes != null && this.codes.length > 0) ? this.codes[this.codes.length - 1] : null; | 		return (this.codes != null && this.codes.length > 0 ? this.codes[this.codes.length - 1] : null); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	@Override | 	@Override | ||||||
|  | @ -127,7 +127,7 @@ public class DefaultMessageSourceResolvable implements MessageSourceResolvable, | ||||||
| 	protected final String resolvableToString() { | 	protected final String resolvableToString() { | ||||||
| 		StringBuilder result = new StringBuilder(); | 		StringBuilder result = new StringBuilder(); | ||||||
| 		result.append("codes [").append(StringUtils.arrayToDelimitedString(this.codes, ",")); | 		result.append("codes [").append(StringUtils.arrayToDelimitedString(this.codes, ",")); | ||||||
| 		result.append("]; arguments [" + StringUtils.arrayToDelimitedString(this.arguments, ",")); | 		result.append("]; arguments [").append(StringUtils.arrayToDelimitedString(this.arguments, ",")); | ||||||
| 		result.append("]; default message [").append(this.defaultMessage).append(']'); | 		result.append("]; default message [").append(this.defaultMessage).append(']'); | ||||||
| 		return result.toString(); | 		return result.toString(); | ||||||
| 	} | 	} | ||||||
|  | @ -153,9 +153,9 @@ public class DefaultMessageSourceResolvable implements MessageSourceResolvable, | ||||||
| 			return false; | 			return false; | ||||||
| 		} | 		} | ||||||
| 		MessageSourceResolvable otherResolvable = (MessageSourceResolvable) other; | 		MessageSourceResolvable otherResolvable = (MessageSourceResolvable) other; | ||||||
| 		return ObjectUtils.nullSafeEquals(getCodes(), otherResolvable.getCodes()) && | 		return (ObjectUtils.nullSafeEquals(getCodes(), otherResolvable.getCodes()) && | ||||||
| 				ObjectUtils.nullSafeEquals(getArguments(), otherResolvable.getArguments()) && | 				ObjectUtils.nullSafeEquals(getArguments(), otherResolvable.getArguments()) && | ||||||
| 				ObjectUtils.nullSafeEquals(getDefaultMessage(), otherResolvable.getDefaultMessage()); | 				ObjectUtils.nullSafeEquals(getDefaultMessage(), otherResolvable.getDefaultMessage())); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	@Override | 	@Override | ||||||
|  |  | ||||||
|  | @ -1,5 +1,5 @@ | ||||||
| /* | /* | ||||||
|  * Copyright 2002-2012 the original author or authors. |  * Copyright 2002-2016 the original author or authors. | ||||||
|  * |  * | ||||||
|  * Licensed under the Apache License, Version 2.0 (the "License"); |  * Licensed under the Apache License, Version 2.0 (the "License"); | ||||||
|  * you may not use this file except in compliance with the License. |  * you may not use this file except in compliance with the License. | ||||||
|  | @ -112,9 +112,9 @@ public class FieldError extends ObjectError { | ||||||
| 			return false; | 			return false; | ||||||
| 		} | 		} | ||||||
| 		FieldError otherError = (FieldError) other; | 		FieldError otherError = (FieldError) other; | ||||||
| 		return getField().equals(otherError.getField()) && | 		return (getField().equals(otherError.getField()) && | ||||||
| 				ObjectUtils.nullSafeEquals(getRejectedValue(), otherError.getRejectedValue()) && | 				ObjectUtils.nullSafeEquals(getRejectedValue(), otherError.getRejectedValue()) && | ||||||
| 				isBindingFailure() == otherError.isBindingFailure(); | 				isBindingFailure() == otherError.isBindingFailure()); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	@Override | 	@Override | ||||||
|  |  | ||||||
|  | @ -1,5 +1,5 @@ | ||||||
| /* | /* | ||||||
|  * Copyright 2002-2015 the original author or authors. |  * Copyright 2002-2016 the original author or authors. | ||||||
|  * |  * | ||||||
|  * Licensed under the Apache License, Version 2.0 (the "License"); |  * Licensed under the Apache License, Version 2.0 (the "License"); | ||||||
|  * you may not use this file except in compliance with the License. |  * you may not use this file except in compliance with the License. | ||||||
|  | @ -78,7 +78,7 @@ public class ObjectError extends DefaultMessageSourceResolvable { | ||||||
| 		if (this == other) { | 		if (this == other) { | ||||||
| 			return true; | 			return true; | ||||||
| 		} | 		} | ||||||
| 		if (getClass() != other.getClass() || !super.equals(other)) { | 		if (other == null || other.getClass() != getClass() || !super.equals(other)) { | ||||||
| 			return false; | 			return false; | ||||||
| 		} | 		} | ||||||
| 		ObjectError otherError = (ObjectError) other; | 		ObjectError otherError = (ObjectError) other; | ||||||
|  |  | ||||||
|  | @ -1,5 +1,5 @@ | ||||||
| /* | /* | ||||||
|  * Copyright 2002-2015 the original author or authors. |  * Copyright 2002-2016 the original author or authors. | ||||||
|  * |  * | ||||||
|  * Licensed under the Apache License, Version 2.0 (the "License"); |  * Licensed under the Apache License, Version 2.0 (the "License"); | ||||||
|  * you may not use this file except in compliance with the License. |  * you may not use this file except in compliance with the License. | ||||||
|  | @ -401,7 +401,7 @@ public class MergedContextConfiguration implements Serializable { | ||||||
| 		if (this == other) { | 		if (this == other) { | ||||||
| 			return true; | 			return true; | ||||||
| 		} | 		} | ||||||
| 		if (!(other instanceof MergedContextConfiguration)) { | 		if (other == null || other.getClass() != getClass()) { | ||||||
| 			return false; | 			return false; | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1,5 +1,5 @@ | ||||||
| /* | /* | ||||||
|  * Copyright 2002-2014 the original author or authors. |  * Copyright 2002-2016 the original author or authors. | ||||||
|  * |  * | ||||||
|  * Licensed under the Apache License, Version 2.0 (the "License"); |  * Licensed under the Apache License, Version 2.0 (the "License"); | ||||||
|  * you may not use this file except in compliance with the License. |  * you may not use this file except in compliance with the License. | ||||||
|  | @ -161,14 +161,8 @@ public class WebMergedContextConfiguration extends MergedContextConfiguration { | ||||||
| 	 */ | 	 */ | ||||||
| 	@Override | 	@Override | ||||||
| 	public boolean equals(Object other) { | 	public boolean equals(Object other) { | ||||||
| 		if (this == other) { | 		return (this == other || (super.equals(other) && | ||||||
| 			return true; | 				this.resourceBasePath.equals(((WebMergedContextConfiguration) other).resourceBasePath))); | ||||||
| 		} |  | ||||||
| 		if (!(other instanceof WebMergedContextConfiguration)) { |  | ||||||
| 			return false; |  | ||||||
| 		} |  | ||||||
| 		WebMergedContextConfiguration otherConfig = (WebMergedContextConfiguration) other; |  | ||||||
| 		return super.equals(otherConfig) && this.getResourceBasePath().equals(otherConfig.getResourceBasePath()); |  | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	/** | 	/** | ||||||
|  | @ -178,7 +172,7 @@ public class WebMergedContextConfiguration extends MergedContextConfiguration { | ||||||
| 	 */ | 	 */ | ||||||
| 	@Override | 	@Override | ||||||
| 	public int hashCode() { | 	public int hashCode() { | ||||||
| 		return 31 * super.hashCode() + this.resourceBasePath.hashCode(); | 		return super.hashCode() * 31 + this.resourceBasePath.hashCode(); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	/** | 	/** | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue