Skip to content

Commit b8706c4

Browse files
izeyesnicoll
authored andcommitted
Use instance equality for Class
Closes gh-11534
1 parent b5a4edc commit b8706c4

File tree

9 files changed

+18
-18
lines changed

9 files changed

+18
-18
lines changed

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationImportSelector.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2017 the original author or authors.
2+
* Copyright 2012-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -108,7 +108,7 @@ public String[] selectImports(AnnotationMetadata annotationMetadata) {
108108
}
109109

110110
protected boolean isEnabled(AnnotationMetadata metadata) {
111-
if (getClass().equals(AutoConfigurationImportSelector.class)) {
111+
if (getClass() == AutoConfigurationImportSelector.class) {
112112
return getEnvironment().getProperty(
113113
EnableAutoConfiguration.ENABLED_OVERRIDE_PROPERTY, Boolean.class,
114114
true);

spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/filter/TypeExcludeFiltersContextCustomizer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2017 the original author or authors.
2+
* Copyright 2012-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -80,7 +80,7 @@ public int hashCode() {
8080

8181
@Override
8282
public boolean equals(Object obj) {
83-
return (obj != null && getClass().equals(obj.getClass()) && this.filters
83+
return (obj != null && getClass() == obj.getClass() && this.filters
8484
.equals(((TypeExcludeFiltersContextCustomizer) obj).filters));
8585
}
8686

spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/PropertyMappingContextCustomizer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2017 the original author or authors.
2+
* Copyright 2012-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -62,7 +62,7 @@ public int hashCode() {
6262

6363
@Override
6464
public boolean equals(Object obj) {
65-
return (obj != null && getClass().equals(obj.getClass()) && this.propertySource
65+
return (obj != null && getClass() == obj.getClass() && this.propertySource
6666
.equals(((PropertyMappingContextCustomizer) obj).propertySource));
6767
}
6868

spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/filter/TypeExcludeFiltersContextCustomizerFactoryTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2017 the original author or authors.
2+
* Copyright 2012-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -125,7 +125,7 @@ public int hashCode() {
125125

126126
@Override
127127
public boolean equals(Object obj) {
128-
return obj.getClass().equals(getClass());
128+
return obj.getClass() == getClass();
129129
}
130130

131131
}

spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleBasicObject.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2017 the original author or authors.
2+
* Copyright 2012-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -40,7 +40,7 @@ public int hashCode() {
4040

4141
@Override
4242
public boolean equals(Object obj) {
43-
if (obj != null && obj.getClass().equals(getClass())) {
43+
if (obj != null && obj.getClass() == getClass()) {
4444
return this.value.equals(((ExampleBasicObject) obj).value);
4545
}
4646
return false;

spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleCustomObject.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2017 the original author or authors.
2+
* Copyright 2012-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -36,7 +36,7 @@ public int hashCode() {
3636

3737
@Override
3838
public boolean equals(Object obj) {
39-
if (obj != null && obj.getClass().equals(getClass())) {
39+
if (obj != null && obj.getClass() == getClass()) {
4040
return this.value.equals(((ExampleCustomObject) obj).value);
4141
}
4242
return false;

spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/ImportsContextCustomizer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2017 the original author or authors.
2+
* Copyright 2012-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -346,7 +346,7 @@ public int hashCode() {
346346

347347
@Override
348348
public boolean equals(Object obj) {
349-
return (obj != null && getClass().equals(obj.getClass())
349+
return (obj != null && getClass() == obj.getClass()
350350
&& this.key.equals(((ContextCustomizerKey) obj).key));
351351
}
352352

spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/util/TestPropertyValues.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2017 the original author or authors.
2+
* Copyright 2012-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -144,7 +144,7 @@ private <E extends Throwable> void rethrow(Throwable e) throws E {
144144
private void addToSources(MutablePropertySources sources, Type type, String name) {
145145
if (sources.contains(name)) {
146146
PropertySource<?> propertySource = sources.get(name);
147-
if (propertySource.getClass().equals(type.getSourceClass())) {
147+
if (propertySource.getClass() == type.getSourceClass()) {
148148
((Map<String, Object>) propertySource.getSource())
149149
.putAll(this.properties);
150150
return;

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/TypeExcludeFilter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2017 the original author or authors.
2+
* Copyright 2012-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -60,7 +60,7 @@ public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
6060
public boolean match(MetadataReader metadataReader,
6161
MetadataReaderFactory metadataReaderFactory) throws IOException {
6262
if (this.beanFactory instanceof ListableBeanFactory
63-
&& getClass().equals(TypeExcludeFilter.class)) {
63+
&& getClass() == TypeExcludeFilter.class) {
6464
Collection<TypeExcludeFilter> delegates = ((ListableBeanFactory) this.beanFactory)
6565
.getBeansOfType(TypeExcludeFilter.class).values();
6666
for (TypeExcludeFilter delegate : delegates) {

0 commit comments

Comments
 (0)