diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/EndpointDiscoverer.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/EndpointDiscoverer.java index 1d46671ccd9..e01b0a91bd1 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/EndpointDiscoverer.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/EndpointDiscoverer.java @@ -382,11 +382,6 @@ public abstract class EndpointDiscoverer, O exten this.description = description; } - @Override - public int hashCode() { - return this.key.hashCode(); - } - @Override public boolean equals(Object obj) { if (obj == this) { @@ -398,6 +393,11 @@ public abstract class EndpointDiscoverer, O exten return this.key.equals(((OperationKey) obj).key); } + @Override + public int hashCode() { + return this.key.hashCode(); + } + @Override public String toString() { return this.description.get(); diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/WebOperationRequestPredicate.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/WebOperationRequestPredicate.java index cf8494b2f58..f571c08df4d 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/WebOperationRequestPredicate.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/WebOperationRequestPredicate.java @@ -89,18 +89,20 @@ public final class WebOperationRequestPredicate { } @Override - public String toString() { - StringBuilder result = new StringBuilder( - this.httpMethod + " to path '" + this.path + "'"); - if (!CollectionUtils.isEmpty(this.consumes)) { - result.append(" consumes: " - + StringUtils.collectionToCommaDelimitedString(this.consumes)); + public boolean equals(Object obj) { + if (this == obj) { + return true; } - if (!CollectionUtils.isEmpty(this.produces)) { - result.append(" produces: " - + StringUtils.collectionToCommaDelimitedString(this.produces)); + if (obj == null || getClass() != obj.getClass()) { + return false; } - return result.toString(); + WebOperationRequestPredicate other = (WebOperationRequestPredicate) obj; + boolean result = true; + result = result && this.consumes.equals(other.consumes); + result = result && this.httpMethod == other.httpMethod; + result = result && this.canonicalPath.equals(other.canonicalPath); + result = result && this.produces.equals(other.produces); + return result; } @Override @@ -115,20 +117,18 @@ public final class WebOperationRequestPredicate { } @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; + public String toString() { + StringBuilder result = new StringBuilder( + this.httpMethod + " to path '" + this.path + "'"); + if (!CollectionUtils.isEmpty(this.consumes)) { + result.append(" consumes: " + + StringUtils.collectionToCommaDelimitedString(this.consumes)); } - if (obj == null || getClass() != obj.getClass()) { - return false; + if (!CollectionUtils.isEmpty(this.produces)) { + result.append(" produces: " + + StringUtils.collectionToCommaDelimitedString(this.produces)); } - WebOperationRequestPredicate other = (WebOperationRequestPredicate) obj; - boolean result = true; - result = result && this.consumes.equals(other.consumes); - result = result && this.httpMethod == other.httpMethod; - result = result && this.canonicalPath.equals(other.canonicalPath); - result = result && this.produces.equals(other.produces); - return result; + return result.toString(); } } diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/Status.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/Status.java index c3a5d89b700..b62ec82388a 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/Status.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/Status.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -102,16 +102,6 @@ public final class Status { return this.description; } - @Override - public String toString() { - return this.code; - } - - @Override - public int hashCode() { - return this.code.hashCode(); - } - @Override public boolean equals(Object obj) { if (obj == this) { @@ -123,4 +113,14 @@ public final class Status { return false; } + @Override + public int hashCode() { + return this.code.hashCode(); + } + + @Override + public String toString() { + return this.code; + } + } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationPackages.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationPackages.java index 2e6ae495e5a..59702c09c2e 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationPackages.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationPackages.java @@ -147,9 +147,8 @@ public abstract class AutoConfigurationPackages { this.packageName = ClassUtils.getPackageName(metadata.getClassName()); } - @Override - public int hashCode() { - return this.packageName.hashCode(); + public String getPackageName() { + return this.packageName; } @Override @@ -160,8 +159,9 @@ public abstract class AutoConfigurationPackages { return this.packageName.equals(((PackageImport) obj).packageName); } - public String getPackageName() { - return this.packageName; + @Override + public int hashCode() { + return this.packageName.hashCode(); } @Override diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionMessage.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionMessage.java index 736b6fac37d..c2cd484287d 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionMessage.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionMessage.java @@ -59,16 +59,6 @@ public final class ConditionMessage { return !StringUtils.hasLength(this.message); } - @Override - public String toString() { - return (this.message != null) ? this.message : ""; - } - - @Override - public int hashCode() { - return ObjectUtils.nullSafeHashCode(this.message); - } - @Override public boolean equals(Object obj) { if (obj == null || !ConditionMessage.class.isInstance(obj)) { @@ -80,6 +70,16 @@ public final class ConditionMessage { return ObjectUtils.nullSafeEquals(((ConditionMessage) obj).message, this.message); } + @Override + public int hashCode() { + return ObjectUtils.nullSafeHashCode(this.message); + } + + @Override + public String toString() { + return (this.message != null) ? this.message : ""; + } + /** * Return a new {@link ConditionMessage} based on the instance and an appended * message. diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionOutcome.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionOutcome.java index 03b0834b690..6e9b7604af4 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionOutcome.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionOutcome.java @@ -122,12 +122,6 @@ public class ConditionOutcome { return this.message; } - @Override - public int hashCode() { - return Boolean.hashCode(this.match) * 31 - + ObjectUtils.nullSafeHashCode(this.message); - } - @Override public boolean equals(Object obj) { if (this == obj) { @@ -144,6 +138,12 @@ public class ConditionOutcome { return super.equals(obj); } + @Override + public int hashCode() { + return Boolean.hashCode(this.match) * 31 + + ObjectUtils.nullSafeHashCode(this.message); + } + @Override public String toString() { return (this.message != null) ? this.message.toString() : ""; diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/embedded/EmbeddedMongoAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/embedded/EmbeddedMongoAutoConfiguration.java index d39c0238074..3db0bb424a3 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/embedded/EmbeddedMongoAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/embedded/EmbeddedMongoAutoConfiguration.java @@ -269,20 +269,6 @@ public class EmbeddedMongoAutoConfiguration { return this.features.contains(feature); } - @Override - public String toString() { - return this.version; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + this.features.hashCode(); - result = prime * result + this.version.hashCode(); - return result; - } - @Override public boolean equals(Object obj) { if (this == obj) { @@ -301,6 +287,20 @@ public class EmbeddedMongoAutoConfiguration { return super.equals(obj); } + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + this.features.hashCode(); + result = prime * result + this.version.hashCode(); + return result; + } + + @Override + public String toString() { + return this.version; + } + } } diff --git a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/dependencies/Dependency.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/dependencies/Dependency.java index 34c8f16fb7a..e703714f065 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/dependencies/Dependency.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/dependencies/Dependency.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -98,22 +98,6 @@ public final class Dependency { return this.exclusions; } - @Override - public String toString() { - return this.groupId + ":" + this.artifactId + ":" + this.version; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + this.groupId.hashCode(); - result = prime * result + this.artifactId.hashCode(); - result = prime * result + this.version.hashCode(); - result = prime * result + this.exclusions.hashCode(); - return result; - } - @Override public boolean equals(Object obj) { if (this == obj) { @@ -134,6 +118,22 @@ public final class Dependency { return false; } + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + this.groupId.hashCode(); + result = prime * result + this.artifactId.hashCode(); + result = prime * result + this.version.hashCode(); + result = prime * result + this.exclusions.hashCode(); + return result; + } + + @Override + public String toString() { + return this.groupId + ":" + this.artifactId + ":" + this.version; + } + /** * A dependency exclusion. */ @@ -166,16 +166,6 @@ public final class Dependency { return this.groupId; } - @Override - public String toString() { - return this.groupId + ":" + this.artifactId; - } - - @Override - public int hashCode() { - return this.groupId.hashCode() * 31 + this.artifactId.hashCode(); - } - @Override public boolean equals(Object obj) { if (this == obj) { @@ -194,6 +184,16 @@ public final class Dependency { return false; } + @Override + public int hashCode() { + return this.groupId.hashCode() * 31 + this.artifactId.hashCode(); + } + + @Override + public String toString() { + return this.groupId + ":" + this.artifactId; + } + } } diff --git a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/RepositoryConfiguration.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/RepositoryConfiguration.java index 73c0a17f584..a0f5e5c2faf 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/RepositoryConfiguration.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/RepositoryConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -54,12 +54,6 @@ public final class RepositoryConfiguration { return this.name; } - @Override - public String toString() { - return "RepositoryConfiguration [name=" + this.name + ", uri=" + this.uri - + ", snapshotsEnabled=" + this.snapshotsEnabled + "]"; - } - /** * Return the URI of the repository. * @return the repository URI @@ -76,11 +70,6 @@ public final class RepositoryConfiguration { return this.snapshotsEnabled; } - @Override - public int hashCode() { - return ObjectUtils.nullSafeHashCode(this.name); - } - @Override public boolean equals(Object obj) { if (this == obj) { @@ -96,4 +85,15 @@ public final class RepositoryConfiguration { return ObjectUtils.nullSafeEquals(this.name, other.name); } + @Override + public int hashCode() { + return ObjectUtils.nullSafeHashCode(this.name); + } + + @Override + public String toString() { + return "RepositoryConfiguration [name=" + this.name + ", uri=" + this.uri + + ", snapshotsEnabled=" + this.snapshotsEnabled + "]"; + } + } diff --git a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/filewatch/ChangedFile.java b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/filewatch/ChangedFile.java index 9490a697ab2..9b450584344 100644 --- a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/filewatch/ChangedFile.java +++ b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/filewatch/ChangedFile.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -81,11 +81,6 @@ public final class ChangedFile { return fileName.substring(folderName.length() + 1); } - @Override - public int hashCode() { - return this.file.hashCode() * 31 + this.type.hashCode(); - } - @Override public boolean equals(Object obj) { if (obj == this) { @@ -101,6 +96,11 @@ public final class ChangedFile { return super.equals(obj); } + @Override + public int hashCode() { + return this.file.hashCode() * 31 + this.type.hashCode(); + } + @Override public String toString() { return this.file + " (" + this.type + ")"; diff --git a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/filewatch/ChangedFiles.java b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/filewatch/ChangedFiles.java index f4482f5b463..54ed503930e 100644 --- a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/filewatch/ChangedFiles.java +++ b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/filewatch/ChangedFiles.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -61,11 +61,6 @@ public final class ChangedFiles implements Iterable { return this.files; } - @Override - public int hashCode() { - return this.files.hashCode(); - } - @Override public boolean equals(Object obj) { if (obj == null) { @@ -82,6 +77,11 @@ public final class ChangedFiles implements Iterable { return super.equals(obj); } + @Override + public int hashCode() { + return this.files.hashCode(); + } + @Override public String toString() { return this.sourceFolder + " " + this.files; diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/OverrideAutoConfigurationContextCustomizerFactory.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/OverrideAutoConfigurationContextCustomizerFactory.java index cc03f386166..4a1e34b4abc 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/OverrideAutoConfigurationContextCustomizerFactory.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/OverrideAutoConfigurationContextCustomizerFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -62,13 +62,13 @@ class OverrideAutoConfigurationContextCustomizerFactory } @Override - public int hashCode() { - return getClass().hashCode(); + public boolean equals(Object obj) { + return (obj != null && obj.getClass() == getClass()); } @Override - public boolean equals(Object obj) { - return (obj != null && obj.getClass() == getClass()); + public int hashCode() { + return getClass().hashCode(); } } diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/filter/AnnotationCustomizableTypeExcludeFilter.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/filter/AnnotationCustomizableTypeExcludeFilter.java index 3207ad95fdb..e59ac1f59e3 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/filter/AnnotationCustomizableTypeExcludeFilter.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/filter/AnnotationCustomizableTypeExcludeFilter.java @@ -117,21 +117,6 @@ public abstract class AnnotationCustomizableTypeExcludeFilter extends TypeExclud } - @Override - public int hashCode() { - final int prime = 31; - int result = 0; - result = prime * result + Boolean.hashCode(hasAnnotation()); - for (FilterType filterType : FilterType.values()) { - result = prime * result - + ObjectUtils.nullSafeHashCode(getFilters(filterType)); - } - result = prime * result + Boolean.hashCode(isUseDefaultFilters()); - result = prime * result + ObjectUtils.nullSafeHashCode(getDefaultIncludes()); - result = prime * result + ObjectUtils.nullSafeHashCode(getComponentIncludes()); - return result; - } - @Override public boolean equals(Object obj) { if (this == obj) { @@ -155,4 +140,19 @@ public abstract class AnnotationCustomizableTypeExcludeFilter extends TypeExclud return result; } + @Override + public int hashCode() { + final int prime = 31; + int result = 0; + result = prime * result + Boolean.hashCode(hasAnnotation()); + for (FilterType filterType : FilterType.values()) { + result = prime * result + + ObjectUtils.nullSafeHashCode(getFilters(filterType)); + } + result = prime * result + Boolean.hashCode(isUseDefaultFilters()); + result = prime * result + ObjectUtils.nullSafeHashCode(getDefaultIncludes()); + result = prime * result + ObjectUtils.nullSafeHashCode(getComponentIncludes()); + return result; + } + } diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/filter/TypeExcludeFiltersContextCustomizer.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/filter/TypeExcludeFiltersContextCustomizer.java index a3df07bf133..66252fefbbc 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/filter/TypeExcludeFiltersContextCustomizer.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/filter/TypeExcludeFiltersContextCustomizer.java @@ -73,17 +73,17 @@ class TypeExcludeFiltersContextCustomizer implements ContextCustomizer { } } - @Override - public int hashCode() { - return this.filters.hashCode(); - } - @Override public boolean equals(Object obj) { return (obj != null && getClass() == obj.getClass() && this.filters .equals(((TypeExcludeFiltersContextCustomizer) obj).filters)); } + @Override + public int hashCode() { + return this.filters.hashCode(); + } + @Override public void customizeContext(ConfigurableApplicationContext context, MergedContextConfiguration mergedContextConfiguration) { diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/AnnotationsPropertySource.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/AnnotationsPropertySource.java index 3ea3c774ec9..6cfaa963774 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/AnnotationsPropertySource.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/AnnotationsPropertySource.java @@ -201,11 +201,6 @@ public class AnnotationsPropertySource extends EnumerablePropertySource return this.properties.isEmpty(); } - @Override - public int hashCode() { - return this.properties.hashCode(); - } - @Override public boolean equals(Object obj) { if (obj == this) { @@ -217,4 +212,9 @@ public class AnnotationsPropertySource extends EnumerablePropertySource return this.properties.equals(((AnnotationsPropertySource) obj).properties); } + @Override + public int hashCode() { + return this.properties.hashCode(); + } + } diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/PropertyMappingContextCustomizer.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/PropertyMappingContextCustomizer.java index 36d2db09782..775478c625f 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/PropertyMappingContextCustomizer.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/PropertyMappingContextCustomizer.java @@ -55,17 +55,17 @@ class PropertyMappingContextCustomizer implements ContextCustomizer { new PropertyMappingCheckBeanPostProcessor()); } - @Override - public int hashCode() { - return this.propertySource.hashCode(); - } - @Override public boolean equals(Object obj) { return (obj != null && getClass() == obj.getClass() && this.propertySource .equals(((PropertyMappingContextCustomizer) obj).propertySource)); } + @Override + public int hashCode() { + return this.propertySource.hashCode(); + } + /** * {@link BeanPostProcessor} to check that {@link PropertyMapping} is only used on * test classes. diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebDriverContextCustomizerFactory.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebDriverContextCustomizerFactory.java index 39e1c04fca6..9d17c49e193 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebDriverContextCustomizerFactory.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebDriverContextCustomizerFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -49,11 +49,6 @@ class WebDriverContextCustomizerFactory implements ContextCustomizerFactory { WebDriverScope.registerWith(context); } - @Override - public int hashCode() { - return getClass().hashCode(); - } - @Override public boolean equals(Object obj) { if (obj == this) { @@ -65,6 +60,11 @@ class WebDriverContextCustomizerFactory implements ContextCustomizerFactory { return true; } + @Override + public int hashCode() { + return getClass().hashCode(); + } + } } diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/filter/TypeExcludeFiltersContextCustomizerFactoryTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/filter/TypeExcludeFiltersContextCustomizerFactoryTests.java index a375465fcec..2d0b73ee8f2 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/filter/TypeExcludeFiltersContextCustomizerFactoryTests.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/filter/TypeExcludeFiltersContextCustomizerFactoryTests.java @@ -119,13 +119,13 @@ public class TypeExcludeFiltersContextCustomizerFactoryTests { } @Override - public int hashCode() { - return SimpleExclude.class.hashCode(); + public boolean equals(Object obj) { + return obj.getClass() == getClass(); } @Override - public boolean equals(Object obj) { - return obj.getClass() == getClass(); + public int hashCode() { + return SimpleExclude.class.hashCode(); } } diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleBasicObject.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleBasicObject.java index 8d99d71ea4d..ba1be0f35a2 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleBasicObject.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleBasicObject.java @@ -33,11 +33,6 @@ public class ExampleBasicObject { this.value = value; } - @Override - public int hashCode() { - return this.value.hashCode(); - } - @Override public boolean equals(Object obj) { if (obj != null && obj.getClass() == getClass()) { @@ -46,4 +41,9 @@ public class ExampleBasicObject { return false; } + @Override + public int hashCode() { + return this.value.hashCode(); + } + } diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleCustomObject.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleCustomObject.java index 3376f45e5fe..372e4f206e1 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleCustomObject.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleCustomObject.java @@ -29,11 +29,6 @@ public class ExampleCustomObject { this.value = value; } - @Override - public int hashCode() { - return this.value.hashCode(); - } - @Override public boolean equals(Object obj) { if (obj != null && obj.getClass() == getClass()) { @@ -42,6 +37,11 @@ public class ExampleCustomObject { return false; } + @Override + public int hashCode() { + return this.value.hashCode(); + } + @Override public String toString() { return this.value; diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleJsonObjectWithView.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleJsonObjectWithView.java index 450c20ce358..76b9ad7b254 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleJsonObjectWithView.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleJsonObjectWithView.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,11 +48,6 @@ public class ExampleJsonObjectWithView { this.id = id; } - @Override - public int hashCode() { - return 0; - } - @Override public boolean equals(Object obj) { if (obj == null || obj.getClass() != getClass()) { @@ -63,6 +58,11 @@ public class ExampleJsonObjectWithView { && ObjectUtils.nullSafeEquals(this.id, other.id); } + @Override + public int hashCode() { + return 0; + } + @Override public String toString() { return this.value + " " + this.id; diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/ImportsContextCustomizer.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/ImportsContextCustomizer.java index fa78ed9108f..8ab6b50e2d2 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/ImportsContextCustomizer.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/ImportsContextCustomizer.java @@ -115,11 +115,6 @@ class ImportsContextCustomizer implements ContextCustomizer { return registry.getBeanDefinition(beanName); } - @Override - public int hashCode() { - return this.key.hashCode(); - } - @Override public boolean equals(Object obj) { if (obj == this) { @@ -133,6 +128,11 @@ class ImportsContextCustomizer implements ContextCustomizer { return this.key.equals(other.key); } + @Override + public int hashCode() { + return this.key.hashCode(); + } + @Override public String toString() { return new ToStringCreator(this).append("key", this.key).toString(); @@ -338,17 +338,17 @@ class ImportsContextCustomizer implements ContextCustomizer { } } - @Override - public int hashCode() { - return this.key.hashCode(); - } - @Override public boolean equals(Object obj) { return (obj != null && getClass() == obj.getClass() && this.key.equals(((ContextCustomizerKey) obj).key)); } + @Override + public int hashCode() { + return this.key.hashCode(); + } + @Override public String toString() { return this.key.toString(); diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/filter/ExcludeFilterContextCustomizer.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/filter/ExcludeFilterContextCustomizer.java index 652a0ec20bf..38ac24c60c4 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/filter/ExcludeFilterContextCustomizer.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/filter/ExcludeFilterContextCustomizer.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,11 +36,6 @@ class ExcludeFilterContextCustomizer implements ContextCustomizer { new TestTypeExcludeFilter()); } - @Override - public int hashCode() { - return getClass().hashCode(); - } - @Override public boolean equals(Object obj) { if (obj == this) { @@ -52,4 +47,9 @@ class ExcludeFilterContextCustomizer implements ContextCustomizer { return true; } + @Override + public int hashCode() { + return getClass().hashCode(); + } + } diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/json/DuplicateJsonObjectContextCustomizerFactory.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/json/DuplicateJsonObjectContextCustomizerFactory.java index 0f043b0e867..bd875e90349 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/json/DuplicateJsonObjectContextCustomizerFactory.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/json/DuplicateJsonObjectContextCustomizerFactory.java @@ -86,11 +86,6 @@ class DuplicateJsonObjectContextCustomizerFactory implements ContextCustomizerFa this.logger.warn(message); } - @Override - public int hashCode() { - return getClass().hashCode(); - } - @Override public boolean equals(Object obj) { if (obj == null || obj.getClass() != getClass()) { @@ -99,6 +94,11 @@ class DuplicateJsonObjectContextCustomizerFactory implements ContextCustomizerFa return true; } + @Override + public int hashCode() { + return getClass().hashCode(); + } + } } diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/Definition.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/Definition.java index 1f25d884a1a..5eaa44a79cb 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/Definition.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/Definition.java @@ -76,17 +76,6 @@ abstract class Definition { return this.qualifier; } - @Override - public int hashCode() { - int result = 1; - result = MULTIPLIER * result + ObjectUtils.nullSafeHashCode(this.name); - result = MULTIPLIER * result + ObjectUtils.nullSafeHashCode(this.reset); - result = MULTIPLIER * result - + ObjectUtils.nullSafeHashCode(this.proxyTargetAware); - result = MULTIPLIER * result + ObjectUtils.nullSafeHashCode(this.qualifier); - return result; - } - @Override public boolean equals(Object obj) { if (obj == this) { @@ -105,4 +94,15 @@ abstract class Definition { return result; } + @Override + public int hashCode() { + int result = 1; + result = MULTIPLIER * result + ObjectUtils.nullSafeHashCode(this.name); + result = MULTIPLIER * result + ObjectUtils.nullSafeHashCode(this.reset); + result = MULTIPLIER * result + + ObjectUtils.nullSafeHashCode(this.proxyTargetAware); + result = MULTIPLIER * result + ObjectUtils.nullSafeHashCode(this.qualifier); + return result; + } + } diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/MockDefinition.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/MockDefinition.java index 8caf8b01963..991d44b666c 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/MockDefinition.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/MockDefinition.java @@ -100,16 +100,6 @@ class MockDefinition extends Definition { return this.serializable; } - @Override - public int hashCode() { - int result = super.hashCode(); - result = MULTIPLIER * result + ObjectUtils.nullSafeHashCode(this.typeToMock); - result = MULTIPLIER * result + ObjectUtils.nullSafeHashCode(this.extraInterfaces); - result = MULTIPLIER * result + ObjectUtils.nullSafeHashCode(this.answer); - result = MULTIPLIER * result + Boolean.hashCode(this.serializable); - return result; - } - @Override public boolean equals(Object obj) { if (obj == this) { @@ -128,6 +118,16 @@ class MockDefinition extends Definition { return result; } + @Override + public int hashCode() { + int result = super.hashCode(); + result = MULTIPLIER * result + ObjectUtils.nullSafeHashCode(this.typeToMock); + result = MULTIPLIER * result + ObjectUtils.nullSafeHashCode(this.extraInterfaces); + result = MULTIPLIER * result + ObjectUtils.nullSafeHashCode(this.answer); + result = MULTIPLIER * result + Boolean.hashCode(this.serializable); + return result; + } + @Override public String toString() { return new ToStringCreator(this).append("name", getName()) diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/MockitoContextCustomizer.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/MockitoContextCustomizer.java index 048f0ab2873..4fd7a1146ca 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/MockitoContextCustomizer.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/MockitoContextCustomizer.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,11 +46,6 @@ class MockitoContextCustomizer implements ContextCustomizer { } } - @Override - public int hashCode() { - return this.definitions.hashCode(); - } - @Override public boolean equals(Object obj) { if (obj == this) { @@ -63,4 +58,9 @@ class MockitoContextCustomizer implements ContextCustomizer { return this.definitions.equals(other.definitions); } + @Override + public int hashCode() { + return this.definitions.hashCode(); + } + } diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/QualifierDefinition.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/QualifierDefinition.java index dad2d1d9720..b5783ea0282 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/QualifierDefinition.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/QualifierDefinition.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -60,11 +60,6 @@ class QualifierDefinition { definition.setQualifiedElement(this.field); } - @Override - public int hashCode() { - return this.annotations.hashCode(); - } - @Override public boolean equals(Object obj) { if (obj == this) { @@ -77,6 +72,11 @@ class QualifierDefinition { return this.annotations.equals(other.annotations); } + @Override + public int hashCode() { + return this.annotations.hashCode(); + } + public static QualifierDefinition forElement(AnnotatedElement element) { if (element != null && element instanceof Field) { Field field = (Field) element; diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/SpyDefinition.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/SpyDefinition.java index 9af4d6eccd9..5d4b240e7ad 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/SpyDefinition.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/SpyDefinition.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -51,13 +51,6 @@ class SpyDefinition extends Definition { return this.typeToSpy; } - @Override - public int hashCode() { - int result = super.hashCode(); - result = MULTIPLIER * result + ObjectUtils.nullSafeHashCode(this.typeToSpy); - return result; - } - @Override public boolean equals(Object obj) { if (obj == this) { @@ -72,6 +65,13 @@ class SpyDefinition extends Definition { return result; } + @Override + public int hashCode() { + int result = super.hashCode(); + result = MULTIPLIER * result + ObjectUtils.nullSafeHashCode(this.typeToSpy); + return result; + } + @Override public String toString() { return new ToStringCreator(this).append("name", getName()) diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/client/TestRestTemplateContextCustomizer.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/client/TestRestTemplateContextCustomizer.java index 4129048c6f2..262d790e5a8 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/client/TestRestTemplateContextCustomizer.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/client/TestRestTemplateContextCustomizer.java @@ -74,11 +74,6 @@ class TestRestTemplateContextCustomizer implements ContextCustomizer { definition); } - @Override - public int hashCode() { - return getClass().hashCode(); - } - @Override public boolean equals(Object obj) { if (obj == null || obj.getClass() != getClass()) { @@ -87,6 +82,11 @@ class TestRestTemplateContextCustomizer implements ContextCustomizer { return true; } + @Override + public int hashCode() { + return getClass().hashCode(); + } + /** * {@link BeanDefinitionRegistryPostProcessor} that runs after the * {@link ConfigurationClassPostProcessor} and add a {@link TestRestTemplateFactory} diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/reactive/server/WebTestClientContextCustomizer.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/reactive/server/WebTestClientContextCustomizer.java index d5292f7b938..0f700d903a9 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/reactive/server/WebTestClientContextCustomizer.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/reactive/server/WebTestClientContextCustomizer.java @@ -78,13 +78,13 @@ class WebTestClientContextCustomizer implements ContextCustomizer { } @Override - public int hashCode() { - return getClass().hashCode(); + public boolean equals(Object obj) { + return (obj != null && obj.getClass() == getClass()); } @Override - public boolean equals(Object obj) { - return (obj != null && obj.getClass() == getClass()); + public int hashCode() { + return getClass().hashCode(); } /** diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/json/ExampleObject.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/json/ExampleObject.java index 3db0036a58a..b7c30a58cce 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/json/ExampleObject.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/json/ExampleObject.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,11 +43,6 @@ public class ExampleObject { this.age = age; } - @Override - public int hashCode() { - return 0; - } - @Override public boolean equals(Object obj) { if (obj == null || obj.getClass() != getClass()) { @@ -58,6 +53,11 @@ public class ExampleObject { && ObjectUtils.nullSafeEquals(this.age, other.age); } + @Override + public int hashCode() { + return 0; + } + @Override public String toString() { return this.name + " " + this.age; diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/json/ExampleObjectWithView.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/json/ExampleObjectWithView.java index 1bd501c0944..1171bb9bbb3 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/json/ExampleObjectWithView.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/json/ExampleObjectWithView.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,11 +48,6 @@ public class ExampleObjectWithView { this.age = age; } - @Override - public int hashCode() { - return 0; - } - @Override public boolean equals(Object obj) { if (obj == null || obj.getClass() != getClass()) { @@ -63,6 +58,11 @@ public class ExampleObjectWithView { && ObjectUtils.nullSafeEquals(this.age, other.age); } + @Override + public int hashCode() { + return 0; + } + @Override public String toString() { return this.name + " " + this.age; diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ItemDeprecation.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ItemDeprecation.java index 64d509e22bd..cba6e71c06f 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ItemDeprecation.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ItemDeprecation.java @@ -68,13 +68,6 @@ public class ItemDeprecation { this.level = level; } - @Override - public String toString() { - return "ItemDeprecation{" + "reason='" + this.reason + '\'' + ", " - + "replacement='" + this.replacement + '\'' + ", " + "level='" - + this.level + '\'' + '}'; - } - @Override public boolean equals(Object o) { if (this == o) { @@ -97,6 +90,13 @@ public class ItemDeprecation { return result; } + @Override + public String toString() { + return "ItemDeprecation{" + "reason='" + this.reason + '\'' + ", " + + "replacement='" + this.replacement + '\'' + ", " + "level='" + + this.level + '\'' + '}'; + } + private boolean nullSafeEquals(Object o1, Object o2) { if (o1 == o2) { return true; diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ItemMetadata.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ItemMetadata.java index b1da40a98c6..4784c04822c 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ItemMetadata.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ItemMetadata.java @@ -133,24 +133,6 @@ public final class ItemMetadata implements Comparable { this.deprecation = deprecation; } - @Override - public String toString() { - StringBuilder string = new StringBuilder(this.name); - buildToStringProperty(string, "type", this.type); - buildToStringProperty(string, "sourceType", this.sourceType); - buildToStringProperty(string, "description", this.description); - buildToStringProperty(string, "defaultValue", this.defaultValue); - buildToStringProperty(string, "deprecation", this.deprecation); - return string.toString(); - } - - protected void buildToStringProperty(StringBuilder string, String property, - Object value) { - if (value != null) { - string.append(" ").append(property).append(":").append(value); - } - } - @Override public boolean equals(Object o) { if (this == o) { @@ -199,6 +181,24 @@ public final class ItemMetadata implements Comparable { return (o != null) ? o.hashCode() : 0; } + @Override + public String toString() { + StringBuilder string = new StringBuilder(this.name); + buildToStringProperty(string, "type", this.type); + buildToStringProperty(string, "sourceType", this.sourceType); + buildToStringProperty(string, "description", this.description); + buildToStringProperty(string, "defaultValue", this.defaultValue); + buildToStringProperty(string, "deprecation", this.deprecation); + return string.toString(); + } + + protected void buildToStringProperty(StringBuilder string, String property, + Object value) { + if (value != null) { + string.append(" ").append(property).append(":").append(value); + } + } + @Override public int compareTo(ItemMetadata o) { return getName().compareTo(o.getName()); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/buildinfo/BuildInfoProperties.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/buildinfo/BuildInfoProperties.java index d335f2209b3..3cf46cba62a 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/buildinfo/BuildInfoProperties.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/buildinfo/BuildInfoProperties.java @@ -162,21 +162,6 @@ public class BuildInfoProperties implements Serializable { this.additionalProperties = additionalProperties; } - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((this.additionalProperties == null) ? 0 - : this.additionalProperties.hashCode()); - result = prime * result - + ((this.artifact == null) ? 0 : this.artifact.hashCode()); - result = prime * result + ((this.group == null) ? 0 : this.group.hashCode()); - result = prime * result + ((this.name == null) ? 0 : this.name.hashCode()); - result = prime * result + ((this.version == null) ? 0 : this.version.hashCode()); - result = prime * result + ((this.time == null) ? 0 : this.time.hashCode()); - return result; - } - @Override public boolean equals(Object obj) { if (this == obj) { @@ -207,4 +192,19 @@ public class BuildInfoProperties implements Serializable { return (o1.equals(o2)); } + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((this.additionalProperties == null) ? 0 + : this.additionalProperties.hashCode()); + result = prime * result + + ((this.artifact == null) ? 0 : this.artifact.hashCode()); + result = prime * result + ((this.group == null) ? 0 : this.group.hashCode()); + result = prime * result + ((this.name == null) ? 0 : this.name.hashCode()); + result = prime * result + ((this.version == null) ? 0 : this.version.hashCode()); + result = prime * result + ((this.time == null) ? 0 : this.time.hashCode()); + return result; + } + } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/LaunchScriptConfiguration.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/LaunchScriptConfiguration.java index f42ce7a0ca5..54c464a2212 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/LaunchScriptConfiguration.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/LaunchScriptConfiguration.java @@ -73,16 +73,6 @@ public class LaunchScriptConfiguration implements Serializable { this.script = script; } - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result - + ((this.properties == null) ? 0 : this.properties.hashCode()); - result = prime * result + ((this.script == null) ? 0 : this.script.hashCode()); - return result; - } - @Override public boolean equals(Object obj) { if (this == obj) { @@ -118,4 +108,14 @@ public class LaunchScriptConfiguration implements Serializable { } } + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + + ((this.properties == null) ? 0 : this.properties.hashCode()); + result = prime * result + ((this.script == null) ? 0 : this.script.hashCode()); + return result; + } + } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/MainClassFinder.java b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/MainClassFinder.java index 85d9f122f38..219e1da8700 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/MainClassFinder.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/MainClassFinder.java @@ -384,16 +384,6 @@ public abstract class MainClassFinder { return this.annotationNames; } - @Override - public String toString() { - return this.name; - } - - @Override - public int hashCode() { - return this.name.hashCode(); - } - @Override public boolean equals(Object obj) { if (this == obj) { @@ -412,6 +402,16 @@ public abstract class MainClassFinder { return true; } + @Override + public int hashCode() { + return this.name.hashCode(); + } + + @Override + public String toString() { + return this.name; + } + } /** diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/AsciiBytes.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/AsciiBytes.java index 9b3fd7aeca2..7ce54335371 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/AsciiBytes.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/AsciiBytes.java @@ -124,20 +124,6 @@ final class AsciiBytes { return new AsciiBytes(this.bytes, this.offset + beginIndex, length); } - @Override - public String toString() { - if (this.string == null) { - if (this.length == 0) { - this.string = EMPTY_STRING; - } - else { - this.string = new String(this.bytes, this.offset, this.length, - StandardCharsets.UTF_8); - } - } - return this.string; - } - public boolean matches(CharSequence name, char suffix) { int charIndex = 0; int nameLen = name.length(); @@ -178,30 +164,6 @@ final class AsciiBytes { return 0; } - @Override - public int hashCode() { - int hash = this.hash; - if (hash == 0 && this.bytes.length > 0) { - for (int i = this.offset; i < this.offset + this.length; i++) { - int b = this.bytes[i]; - int remainingUtfBytes = getNumberOfUtfBytes(b) - 1; - b &= INITIAL_BYTE_BITMASK[remainingUtfBytes]; - for (int j = 0; j < remainingUtfBytes; j++) { - b = (b << 6) + (this.bytes[++i] & SUBSEQUENT_BYTE_BITMASK); - } - if (b <= 0xFFFF) { - hash = 31 * hash + b; - } - else { - hash = 31 * hash + ((b >> 0xA) + 0xD7C0); - hash = 31 * hash + ((b & 0x3FF) + 0xDC00); - } - } - this.hash = hash; - } - return hash; - } - private int getNumberOfUtfBytes(int b) { if ((b & 0x80) == 0) { return 1; @@ -236,6 +198,44 @@ final class AsciiBytes { return false; } + @Override + public int hashCode() { + int hash = this.hash; + if (hash == 0 && this.bytes.length > 0) { + for (int i = this.offset; i < this.offset + this.length; i++) { + int b = this.bytes[i]; + int remainingUtfBytes = getNumberOfUtfBytes(b) - 1; + b &= INITIAL_BYTE_BITMASK[remainingUtfBytes]; + for (int j = 0; j < remainingUtfBytes; j++) { + b = (b << 6) + (this.bytes[++i] & SUBSEQUENT_BYTE_BITMASK); + } + if (b <= 0xFFFF) { + hash = 31 * hash + b; + } + else { + hash = 31 * hash + ((b >> 0xA) + 0xD7C0); + hash = 31 * hash + ((b & 0x3FF) + 0xDC00); + } + } + this.hash = hash; + } + return hash; + } + + @Override + public String toString() { + if (this.string == null) { + if (this.length == 0) { + this.string = EMPTY_STRING; + } + else { + this.string = new String(this.bytes, this.offset, this.length, + StandardCharsets.UTF_8); + } + } + return this.string; + } + static String toString(byte[] bytes) { return new String(bytes, StandardCharsets.UTF_8); } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/StringSequence.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/StringSequence.java index 67beac47b88..896c45561b1 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/StringSequence.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/StringSequence.java @@ -106,23 +106,6 @@ final class StringSequence implements CharSequence { return subSequence(offset, offset + prefix.length()).equals(prefix); } - @Override - public String toString() { - return this.source.substring(this.start, this.end); - } - - @Override - public int hashCode() { - int hash = this.hash; - if (hash == 0 && length() > 0) { - for (int i = this.start; i < this.end; i++) { - hash = 31 * hash + this.source.charAt(i); - } - this.hash = hash; - } - return hash; - } - @Override public boolean equals(Object obj) { if (this == obj) { @@ -146,4 +129,21 @@ final class StringSequence implements CharSequence { return true; } + @Override + public int hashCode() { + int hash = this.hash; + if (hash == 0 && length() > 0) { + for (int i = this.start; i < this.end; i++) { + hash = 31 * hash + this.source.charAt(i); + } + this.hash = hash; + } + return hash; + } + + @Override + public String toString() { + return this.source.substring(this.start, this.end); + } + } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/builder/ParentContextCloserApplicationListener.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/builder/ParentContextCloserApplicationListener.java index 9f69bd5dd27..2499e70d3dd 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/builder/ParentContextCloserApplicationListener.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/builder/ParentContextCloserApplicationListener.java @@ -101,11 +101,6 @@ public class ParentContextCloserApplicationListener } } - @Override - public int hashCode() { - return ObjectUtils.nullSafeHashCode(this.childContext.get()); - } - @Override public boolean equals(Object obj) { if (this == obj) { @@ -122,6 +117,11 @@ public class ParentContextCloserApplicationListener return super.equals(obj); } + @Override + public int hashCode() { + return ObjectUtils.nullSafeHashCode(this.childContext.get()); + } + } } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigFileApplicationListener.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigFileApplicationListener.java index 15af937b0b5..1ecda01dd5e 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigFileApplicationListener.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigFileApplicationListener.java @@ -733,16 +733,6 @@ public class ConfigFileApplicationListener return this.defaultProfile; } - @Override - public String toString() { - return this.name; - } - - @Override - public int hashCode() { - return this.name.hashCode(); - } - @Override public boolean equals(Object obj) { if (obj == this) { @@ -754,6 +744,16 @@ public class ConfigFileApplicationListener return ((Profile) obj).name.equals(this.name); } + @Override + public int hashCode() { + return this.name.hashCode(); + } + + @Override + public String toString() { + return this.name; + } + } /** @@ -770,11 +770,6 @@ public class ConfigFileApplicationListener this.resource = resource; } - @Override - public int hashCode() { - return this.loader.hashCode() * 31 + this.resource.hashCode(); - } - @Override public boolean equals(Object obj) { if (this == obj) { @@ -788,6 +783,11 @@ public class ConfigFileApplicationListener && this.resource.equals(other.resource); } + @Override + public int hashCode() { + return this.loader.hashCode() * 31 + this.resource.hashCode(); + } + } /** diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/BindResult.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/BindResult.java index d9a432793bf..f1ff739fa7d 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/BindResult.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/BindResult.java @@ -140,11 +140,6 @@ public final class BindResult { return this.value; } - @Override - public int hashCode() { - return ObjectUtils.nullSafeHashCode(this.value); - } - @Override public boolean equals(Object obj) { if (this == obj) { @@ -156,6 +151,11 @@ public final class BindResult { return ObjectUtils.nullSafeEquals(this.value, ((BindResult) obj).value); } + @Override + public int hashCode() { + return ObjectUtils.nullSafeHashCode(this.value); + } + @SuppressWarnings("unchecked") static BindResult of(T value) { if (value == null) { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/Bindable.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/Bindable.java index 645fbf2feea..09ba0a9dc72 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/Bindable.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/Bindable.java @@ -106,24 +106,6 @@ public final class Bindable { return null; } - @Override - public String toString() { - ToStringCreator creator = new ToStringCreator(this); - creator.append("type", this.type); - creator.append("value", (this.value != null) ? "provided" : "none"); - creator.append("annotations", this.annotations); - return creator.toString(); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ObjectUtils.nullSafeHashCode(this.type); - result = prime * result + ObjectUtils.nullSafeHashCode(this.annotations); - return result; - } - @Override public boolean equals(Object obj) { if (this == obj) { @@ -139,6 +121,24 @@ public final class Bindable { return result; } + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ObjectUtils.nullSafeHashCode(this.type); + result = prime * result + ObjectUtils.nullSafeHashCode(this.annotations); + return result; + } + + @Override + public String toString() { + ToStringCreator creator = new ToStringCreator(this); + creator.append("type", this.type); + creator.append("value", (this.value != null) ? "provided" : "none"); + creator.append("annotations", this.annotations); + return creator.toString(); + } + private boolean nullSafeEquals(Object o1, Object o2) { return ObjectUtils.nullSafeEquals(o1, o2); } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationProperty.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationProperty.java index 30ded56ab33..d8b359c1943 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationProperty.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationProperty.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -63,13 +63,6 @@ public final class ConfigurationProperty return this.origin; } - @Override - public int hashCode() { - int result = ObjectUtils.nullSafeHashCode(this.name); - result = 31 * result + ObjectUtils.nullSafeHashCode(this.value); - return result; - } - @Override public boolean equals(Object obj) { if (this == obj) { @@ -85,6 +78,13 @@ public final class ConfigurationProperty return result; } + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(this.name); + result = 31 * result + ObjectUtils.nullSafeHashCode(this.value); + return result; + } + @Override public String toString() { return new ToStringCreator(this).append("name", this.name) diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationPropertyName.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationPropertyName.java index 0be25c053df..34326b67694 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationPropertyName.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationPropertyName.java @@ -295,62 +295,6 @@ public final class ConfigurationPropertyName return e1.compareTo(e2); } - @Override - public String toString() { - if (this.string == null) { - this.string = toString(this.elements); - } - return this.string; - } - - private String toString(CharSequence[] elements) { - StringBuilder result = new StringBuilder(); - for (CharSequence element : elements) { - boolean indexed = isIndexed(element); - if (result.length() > 0 && !indexed) { - result.append("."); - } - if (indexed) { - result.append(element); - } - else { - for (int i = 0; i < element.length(); i++) { - char ch = Character.toLowerCase(element.charAt(i)); - result.append((ch != '_') ? ch : ""); - } - } - } - return result.toString(); - } - - @Override - public int hashCode() { - if (this.elementHashCodes == null) { - this.elementHashCodes = getElementHashCodes(); - } - return ObjectUtils.nullSafeHashCode(this.elementHashCodes); - } - - private int[] getElementHashCodes() { - int[] hashCodes = new int[this.elements.length]; - for (int i = 0; i < this.elements.length; i++) { - hashCodes[i] = getElementHashCode(this.elements[i]); - } - return hashCodes; - } - - private int getElementHashCode(CharSequence element) { - int hash = 0; - boolean indexed = isIndexed(element); - int offset = (indexed ? 1 : 0); - for (int i = 0 + offset; i < element.length() - offset; i++) { - char ch = (indexed ? element.charAt(i) - : Character.toLowerCase(element.charAt(i))); - hash = (ch == '-' || ch == '_') ? hash : 31 * hash + Character.hashCode(ch); - } - return hash; - } - @Override public boolean equals(Object obj) { if (obj == this) { @@ -409,6 +353,62 @@ public final class ConfigurationPropertyName return true; } + @Override + public int hashCode() { + if (this.elementHashCodes == null) { + this.elementHashCodes = getElementHashCodes(); + } + return ObjectUtils.nullSafeHashCode(this.elementHashCodes); + } + + private int[] getElementHashCodes() { + int[] hashCodes = new int[this.elements.length]; + for (int i = 0; i < this.elements.length; i++) { + hashCodes[i] = getElementHashCode(this.elements[i]); + } + return hashCodes; + } + + private int getElementHashCode(CharSequence element) { + int hash = 0; + boolean indexed = isIndexed(element); + int offset = (indexed ? 1 : 0); + for (int i = 0 + offset; i < element.length() - offset; i++) { + char ch = (indexed ? element.charAt(i) + : Character.toLowerCase(element.charAt(i))); + hash = (ch == '-' || ch == '_') ? hash : 31 * hash + Character.hashCode(ch); + } + return hash; + } + + @Override + public String toString() { + if (this.string == null) { + this.string = toString(this.elements); + } + return this.string; + } + + private String toString(CharSequence[] elements) { + StringBuilder result = new StringBuilder(); + for (CharSequence element : elements) { + boolean indexed = isIndexed(element); + if (result.length() > 0 && !indexed) { + result.append("."); + } + if (indexed) { + result.append(element); + } + else { + for (int i = 0; i < element.length(); i++) { + char ch = Character.toLowerCase(element.charAt(i)); + result.append((ch != '_') ? ch : ""); + } + } + } + return result.toString(); + } + private static boolean isIndexed(CharSequence element) { return element.charAt(0) == '[' && element.charAt(element.length() - 1) == ']'; } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/SpringIterableConfigurationPropertySource.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/SpringIterableConfigurationPropertySource.java index 0ccbb61d61f..8fff79f0650 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/SpringIterableConfigurationPropertySource.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/SpringIterableConfigurationPropertySource.java @@ -191,11 +191,6 @@ class SpringIterableConfigurationPropertySource extends SpringConfigurationPrope return ((String[]) key).clone(); } - @Override - public int hashCode() { - return this.key.hashCode(); - } - @Override public boolean equals(Object obj) { if (this == obj) { @@ -207,6 +202,11 @@ class SpringIterableConfigurationPropertySource extends SpringConfigurationPrope return ObjectUtils.nullSafeEquals(this.key, ((CacheKey) obj).key); } + @Override + public int hashCode() { + return this.key.hashCode(); + } + public static CacheKey get(EnumerablePropertySource source) { if (source instanceof MapPropertySource) { return new CacheKey(((MapPropertySource) source).getSource().keySet()); diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/BeanCurrentlyInCreationFailureAnalyzer.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/BeanCurrentlyInCreationFailureAnalyzer.java index 3c9765d6dd0..588251ef54b 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/BeanCurrentlyInCreationFailureAnalyzer.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/BeanCurrentlyInCreationFailureAnalyzer.java @@ -139,11 +139,6 @@ class BeanCurrentlyInCreationFailureAnalyzer return ((UnsatisfiedDependencyException) ex).getInjectionPoint(); } - @Override - public int hashCode() { - return this.name.hashCode(); - } - @Override public boolean equals(Object obj) { if (this == obj) { @@ -155,6 +150,11 @@ class BeanCurrentlyInCreationFailureAnalyzer return this.name.equals(((BeanInCycle) obj).name); } + @Override + public int hashCode() { + return this.name.hashCode(); + } + @Override public String toString() { return this.name + this.description; diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/LoggerConfiguration.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/LoggerConfiguration.java index 5e9bbe26b0d..73df6b6012d 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/LoggerConfiguration.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/LoggerConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -72,22 +72,6 @@ public final class LoggerConfiguration { return this.name; } - @Override - public String toString() { - return "LoggerConfiguration [name=" + this.name + ", configuredLevel=" - + this.configuredLevel + ", effectiveLevel=" + this.effectiveLevel + "]"; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ObjectUtils.nullSafeHashCode(this.name); - result = prime * result + ObjectUtils.nullSafeHashCode(this.configuredLevel); - result = prime * result + ObjectUtils.nullSafeHashCode(this.effectiveLevel); - return result; - } - @Override public boolean equals(Object obj) { if (this == obj) { @@ -109,4 +93,20 @@ public final class LoggerConfiguration { return super.equals(obj); } + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ObjectUtils.nullSafeHashCode(this.name); + result = prime * result + ObjectUtils.nullSafeHashCode(this.configuredLevel); + result = prime * result + ObjectUtils.nullSafeHashCode(this.effectiveLevel); + return result; + } + + @Override + public String toString() { + return "LoggerConfiguration [name=" + this.name + ", configuredLevel=" + + this.configuredLevel + ", effectiveLevel=" + this.effectiveLevel + "]"; + } + } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/origin/OriginTrackedValue.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/origin/OriginTrackedValue.java index 1a9bcc6fab5..2270692595f 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/origin/OriginTrackedValue.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/origin/OriginTrackedValue.java @@ -52,8 +52,11 @@ public class OriginTrackedValue implements OriginProvider { } @Override - public String toString() { - return (this.value != null) ? this.value.toString() : null; + public boolean equals(Object obj) { + if (obj == null || obj.getClass() != getClass()) { + return false; + } + return ObjectUtils.nullSafeEquals(this.value, ((OriginTrackedValue) obj).value); } @Override @@ -62,11 +65,8 @@ public class OriginTrackedValue implements OriginProvider { } @Override - public boolean equals(Object obj) { - if (obj == null || obj.getClass() != getClass()) { - return false; - } - return ObjectUtils.nullSafeEquals(this.value, ((OriginTrackedValue) obj).value); + public String toString() { + return (this.value != null) ? this.value.toString() : null; } public static OriginTrackedValue of(Object value) { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/origin/SystemEnvironmentOrigin.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/origin/SystemEnvironmentOrigin.java index f939ad18218..77688fc68e9 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/origin/SystemEnvironmentOrigin.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/origin/SystemEnvironmentOrigin.java @@ -40,16 +40,6 @@ public class SystemEnvironmentOrigin implements Origin { return this.property; } - @Override - public String toString() { - return "System Environment Property \"" + this.property + "\""; - } - - @Override - public int hashCode() { - return ObjectUtils.nullSafeHashCode(this.property); - } - @Override public boolean equals(Object obj) { if (this == obj) { @@ -62,4 +52,14 @@ public class SystemEnvironmentOrigin implements Origin { return ObjectUtils.nullSafeEquals(this.property, other.property); } + @Override + public int hashCode() { + return ObjectUtils.nullSafeHashCode(this.property); + } + + @Override + public String toString() { + return "System Environment Property \"" + this.property + "\""; + } + } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/origin/TextResourceOrigin.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/origin/TextResourceOrigin.java index cd7fd5eb671..d8c965f971e 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/origin/TextResourceOrigin.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/origin/TextResourceOrigin.java @@ -54,14 +54,6 @@ public class TextResourceOrigin implements Origin { return this.location; } - @Override - public int hashCode() { - int result = 1; - result = 31 * result + ObjectUtils.nullSafeHashCode(this.resource); - result = 31 * result + ObjectUtils.nullSafeHashCode(this.location); - return result; - } - @Override public boolean equals(Object obj) { if (this == obj) { @@ -80,6 +72,14 @@ public class TextResourceOrigin implements Origin { return super.equals(obj); } + @Override + public int hashCode() { + int result = 1; + result = 31 * result + ObjectUtils.nullSafeHashCode(this.resource); + result = 31 * result + ObjectUtils.nullSafeHashCode(this.location); + return result; + } + @Override public String toString() { StringBuilder result = new StringBuilder(); @@ -126,11 +126,6 @@ public class TextResourceOrigin implements Origin { return this.column; } - @Override - public int hashCode() { - return (31 * this.line) + this.column; - } - @Override public boolean equals(Object obj) { if (this == obj) { @@ -146,6 +141,11 @@ public class TextResourceOrigin implements Origin { return result; } + @Override + public int hashCode() { + return (31 * this.line) + this.column; + } + @Override public String toString() { return (this.line + 1) + ":" + (this.column + 1); diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/system/ApplicationPid.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/system/ApplicationPid.java index fad8b0fea3d..cd07e1eacb1 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/system/ApplicationPid.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/system/ApplicationPid.java @@ -60,16 +60,6 @@ public class ApplicationPid { } } - @Override - public String toString() { - return (this.pid != null) ? this.pid : "???"; - } - - @Override - public int hashCode() { - return ObjectUtils.nullSafeHashCode(this.pid); - } - @Override public boolean equals(Object obj) { if (obj == this) { @@ -81,6 +71,16 @@ public class ApplicationPid { return false; } + @Override + public int hashCode() { + return ObjectUtils.nullSafeHashCode(this.pid); + } + + @Override + public String toString() { + return (this.pid != null) ? this.pid : "???"; + } + /** * Write the PID to the specified file. * @param file the PID file diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServer.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServer.java index fdc2e33ba1c..53a3f978330 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServer.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServer.java @@ -340,16 +340,6 @@ public class UndertowServletWebServer implements WebServer { return this.number; } - @Override - public String toString() { - return this.number + " (" + this.protocol + ")"; - } - - @Override - public int hashCode() { - return this.number; - } - @Override public boolean equals(Object obj) { if (this == obj) { @@ -368,6 +358,16 @@ public class UndertowServletWebServer implements WebServer { return true; } + @Override + public int hashCode() { + return this.number; + } + + @Override + public String toString() { + return this.number + " (" + this.protocol + ")"; + } + } } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowWebServer.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowWebServer.java index 1a643dcd4c6..4f56d7847ef 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowWebServer.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowWebServer.java @@ -268,16 +268,6 @@ public class UndertowWebServer implements WebServer { return this.number; } - @Override - public String toString() { - return this.number + " (" + this.protocol + ")"; - } - - @Override - public int hashCode() { - return this.number; - } - @Override public boolean equals(Object obj) { if (this == obj) { @@ -296,6 +286,16 @@ public class UndertowWebServer implements WebServer { return true; } + @Override + public int hashCode() { + return this.number; + } + + @Override + public String toString() { + return this.number + " (" + this.protocol + ")"; + } + } } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/server/ErrorPage.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/server/ErrorPage.java index 180fbcc400d..a6ca4a6c29b 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/server/ErrorPage.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/server/ErrorPage.java @@ -104,16 +104,6 @@ public class ErrorPage { return (this.status == null && this.exception == null); } - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ObjectUtils.nullSafeHashCode(getExceptionName()); - result = prime * result + ObjectUtils.nullSafeHashCode(this.path); - result = prime * result + this.getStatusCode(); - return result; - } - @Override public boolean equals(Object obj) { if (this == obj) { @@ -134,4 +124,14 @@ public class ErrorPage { return false; } + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ObjectUtils.nullSafeHashCode(getExceptionName()); + result = prime * result + ObjectUtils.nullSafeHashCode(this.path); + result = prime * result + this.getStatusCode(); + return result; + } + } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/server/MimeMappings.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/server/MimeMappings.java index f3fa83b026e..da216393137 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/server/MimeMappings.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/server/MimeMappings.java @@ -302,11 +302,6 @@ public final class MimeMappings implements Iterable { return (previous != null) ? previous.getMimeType() : null; } - @Override - public int hashCode() { - return this.map.hashCode(); - } - @Override public boolean equals(Object obj) { if (obj == null) { @@ -322,6 +317,11 @@ public final class MimeMappings implements Iterable { return false; } + @Override + public int hashCode() { + return this.map.hashCode(); + } + /** * Create a new unmodifiable view of the specified mapping. Methods that attempt to * modify the returned map will throw {@link UnsupportedOperationException}s. @@ -356,11 +356,6 @@ public final class MimeMappings implements Iterable { return this.mimeType; } - @Override - public int hashCode() { - return this.extension.hashCode(); - } - @Override public boolean equals(Object obj) { if (obj == null) { @@ -377,6 +372,11 @@ public final class MimeMappings implements Iterable { return false; } + @Override + public int hashCode() { + return this.extension.hashCode(); + } + @Override public String toString() { return "Mapping [extension=" + this.extension + ", mimeType=" + this.mimeType diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/origin/MockOrigin.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/origin/MockOrigin.java index b209eb9db0e..d5b93e57a76 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/origin/MockOrigin.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/origin/MockOrigin.java @@ -32,11 +32,6 @@ public final class MockOrigin implements Origin { this.value = value; } - @Override - public int hashCode() { - return this.value.hashCode(); - } - @Override public boolean equals(Object obj) { if (this == obj) { @@ -48,6 +43,11 @@ public final class MockOrigin implements Origin { return this.value.equals(((MockOrigin) obj).value); } + @Override + public int hashCode() { + return this.value.hashCode(); + } + @Override public String toString() { return this.value;