Skip to content

Commit ddb769b

Browse files
committed
Polish 'Simplify conditionals'
See gh-39259
1 parent 65a1ff8 commit ddb769b

File tree

7 files changed

+17
-10
lines changed

7 files changed

+17
-10
lines changed

spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/invoke/reflect/OperationMethodParameter.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,10 @@ public boolean isMandatory() {
6868
if (!ObjectUtils.isEmpty(this.parameter.getAnnotationsByType(Nullable.class))) {
6969
return false;
7070
}
71-
return !jsr305Present || new Jsr305().isMandatory(this.parameter);
71+
if (jsr305Present) {
72+
return new Jsr305().isMandatory(this.parameter);
73+
}
74+
return true;
7275
}
7376

7477
@Override

spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/classloader/ClassLoaderFile.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,12 @@ public ClassLoaderFile(Kind kind, byte[] contents) {
5555
*/
5656
public ClassLoaderFile(Kind kind, long lastModified, byte[] contents) {
5757
Assert.notNull(kind, "Kind must not be null");
58-
Assert.isTrue((kind != Kind.DELETED) == (contents != null),
59-
() -> "Contents must " + ((kind != Kind.DELETED) ? "not " : "") + "be null");
58+
if (kind == Kind.DELETED) {
59+
Assert.isTrue(contents == null, "Contents must be null");
60+
}
61+
else {
62+
Assert.isTrue(contents != null, "Contents must not be null");
63+
}
6064
this.kind = kind;
6165
this.lastModified = lastModified;
6266
this.contents = contents;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public ContextCustomizer createContextCustomizer(Class<?> testClass,
4444
}
4545
OverrideAutoConfiguration overrideAutoConfiguration = TestContextAnnotationUtils.findMergedAnnotation(testClass,
4646
OverrideAutoConfiguration.class);
47-
boolean enabled = overrideAutoConfiguration == null || overrideAutoConfiguration.enabled();
47+
boolean enabled = (overrideAutoConfiguration == null) || overrideAutoConfiguration.enabled();
4848
return !enabled ? new DisableAutoConfigurationContextCustomizer() : null;
4949
}
5050

spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/net/protocol/jar/JarUrlConnection.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ public InputStream getInputStream() throws IOException {
207207

208208
@Override
209209
public boolean getAllowUserInteraction() {
210-
return this.jarFileConnection != null && this.jarFileConnection.getAllowUserInteraction();
210+
return (this.jarFileConnection != null) && this.jarFileConnection.getAllowUserInteraction();
211211
}
212212

213213
@Override
@@ -219,7 +219,7 @@ public void setAllowUserInteraction(boolean allowuserinteraction) {
219219

220220
@Override
221221
public boolean getUseCaches() {
222-
return this.jarFileConnection == null || this.jarFileConnection.getUseCaches();
222+
return (this.jarFileConnection == null) || this.jarFileConnection.getUseCaches();
223223
}
224224

225225
@Override
@@ -231,7 +231,7 @@ public void setUseCaches(boolean usecaches) {
231231

232232
@Override
233233
public boolean getDefaultUseCaches() {
234-
return this.jarFileConnection == null || this.jarFileConnection.getDefaultUseCaches();
234+
return (this.jarFileConnection == null) || this.jarFileConnection.getDefaultUseCaches();
235235
}
236236

237237
@Override

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/DefaultBindConstructorProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ private static boolean isAutowiredPresent(Class<?> type) {
127127
return true;
128128
}
129129
Class<?> userClass = ClassUtils.getUserClass(type);
130-
return userClass != type && isAutowiredPresent(userClass);
130+
return (userClass != type) && isAutowiredPresent(userClass);
131131
}
132132

133133
private static Constructor<?>[] getCandidateConstructors(Class<?> type) {

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/SpringProfileArbiter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ private SpringProfileArbiter(Environment environment, String[] profiles) {
5353

5454
@Override
5555
public boolean isCondition() {
56-
return this.environment != null && this.environment.acceptsProfiles(this.profiles);
56+
return (this.environment != null) && this.environment.acceptsProfiles(this.profiles);
5757
}
5858

5959
@PluginBuilderFactory

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/NestedJarResourceSet.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ protected boolean isMultiRelease() {
124124
// JarFile.isMultiRelease() is final so we must go to the manifest
125125
Manifest manifest = getManifest();
126126
Attributes attributes = (manifest != null) ? manifest.getMainAttributes() : null;
127-
this.multiRelease = attributes != null && attributes.containsKey(MULTI_RELEASE);
127+
this.multiRelease = (attributes != null) && attributes.containsKey(MULTI_RELEASE);
128128
}
129129
}
130130
}

0 commit comments

Comments
 (0)