Merge pull request #22528 from pradipta

* pr/22528:
  Polish "Removed some redundant 'else's using early return"
  Removed some redundant 'else's using early return

Closes gh-22528
This commit is contained in:
Stephane Nicoll
2020-09-01 13:36:43 +02:00
4 changed files with 17 additions and 26 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2020 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.
@@ -77,13 +77,11 @@ public abstract class AbstractEndpointDocumentationTests {
Object target = payload;
Map<Object, Object> parent = null;
for (String key : keys) {
if (target instanceof Map) {
parent = (Map<Object, Object>) target;
target = parent.get(key);
}
else {
if (!(target instanceof Map)) {
throw new IllegalStateException();
}
parent = (Map<Object, Object>) target;
target = parent.get(key);
}
if (target instanceof Map) {
parent.put(keys[keys.length - 1], select((Map<String, Object>) target, filter));

View File

@@ -404,9 +404,7 @@ public class ConfigurationPropertiesReportEndpoint implements ApplicationContext
return Arrays.stream(bindConstructor.getParameters())
.anyMatch((parameter) -> parameter.getName().equals(writer.getName()));
}
else {
return isReadable(beanDesc, writer);
}
return isReadable(beanDesc, writer);
}
private boolean isReadable(BeanDescription beanDesc, BeanPropertyWriter writer) {

View File

@@ -152,19 +152,17 @@ public abstract class ResourceUtils {
if (location.startsWith(CLASSPATH_URL_PREFIX)) {
return new ClassPathResource(location.substring(CLASSPATH_URL_PREFIX.length()), getClassLoader());
}
else {
if (location.startsWith(FILE_URL_PREFIX)) {
return this.files.getResource(location);
}
try {
// Try to parse the location as a URL...
URL url = new URL(location);
return new UrlResource(url);
}
catch (MalformedURLException ex) {
// No URL -> resolve as resource path.
return getResourceByPath(location);
}
if (location.startsWith(FILE_URL_PREFIX)) {
return this.files.getResource(location);
}
try {
// Try to parse the location as a URL...
URL url = new URL(location);
return new UrlResource(url);
}
catch (MalformedURLException ex) {
// No URL -> resolve as resource path.
return getResourceByPath(location);
}
}

View File

@@ -127,10 +127,7 @@ class PropertyMigration {
return String.format("Reason: Replacement key '%s' uses an incompatible target type",
deprecation.getReplacement());
}
else {
return String.format("Reason: No metadata found for replacement key '%s'",
deprecation.getReplacement());
}
return String.format("Reason: No metadata found for replacement key '%s'", deprecation.getReplacement());
}
return "Reason: none";
}