Removed some redundant 'else's using early return

See gh-22528
pull/23161/head
Pradipta Sarma 4 years ago committed by Stephane Nicoll
parent 72c6435078
commit 2627bf896e

@ -77,13 +77,11 @@ public abstract class AbstractEndpointDocumentationTests {
Object target = payload; Object target = payload;
Map<Object, Object> parent = null; Map<Object, Object> parent = null;
for (String key : keys) { for (String key : keys) {
if (target instanceof Map) { if (!(target instanceof Map)) {
parent = (Map<Object, Object>) target;
target = parent.get(key);
}
else {
throw new IllegalStateException(); throw new IllegalStateException();
} }
parent = (Map<Object, Object>) target;
target = parent.get(key);
} }
if (target instanceof Map) { if (target instanceof Map) {
parent.put(keys[keys.length - 1], select((Map<String, Object>) target, filter)); parent.put(keys[keys.length - 1], select((Map<String, Object>) target, filter));

@ -404,10 +404,8 @@ public class ConfigurationPropertiesReportEndpoint implements ApplicationContext
return Arrays.stream(bindConstructor.getParameters()) return Arrays.stream(bindConstructor.getParameters())
.anyMatch((parameter) -> parameter.getName().equals(writer.getName())); .anyMatch((parameter) -> parameter.getName().equals(writer.getName()));
} }
else {
return isReadable(beanDesc, writer); return isReadable(beanDesc, writer);
} }
}
private boolean isReadable(BeanDescription beanDesc, BeanPropertyWriter writer) { private boolean isReadable(BeanDescription beanDesc, BeanPropertyWriter writer) {
Class<?> parentType = beanDesc.getType().getRawClass(); Class<?> parentType = beanDesc.getType().getRawClass();

@ -152,7 +152,6 @@ public abstract class ResourceUtils {
if (location.startsWith(CLASSPATH_URL_PREFIX)) { if (location.startsWith(CLASSPATH_URL_PREFIX)) {
return new ClassPathResource(location.substring(CLASSPATH_URL_PREFIX.length()), getClassLoader()); return new ClassPathResource(location.substring(CLASSPATH_URL_PREFIX.length()), getClassLoader());
} }
else {
if (location.startsWith(FILE_URL_PREFIX)) { if (location.startsWith(FILE_URL_PREFIX)) {
return this.files.getResource(location); return this.files.getResource(location);
} }
@ -166,7 +165,6 @@ public abstract class ResourceUtils {
return getResourceByPath(location); return getResourceByPath(location);
} }
} }
}
} }

@ -127,10 +127,7 @@ class PropertyMigration {
return String.format("Reason: Replacement key '%s' uses an incompatible target type", return String.format("Reason: Replacement key '%s' uses an incompatible target type",
deprecation.getReplacement()); 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"; return "Reason: none";
} }

@ -596,12 +596,10 @@ public class JSONObject {
*/ */
public JSONArray getJSONArray(String name) throws JSONException { public JSONArray getJSONArray(String name) throws JSONException {
Object object = get(name); Object object = get(name);
if (object instanceof JSONArray) { if (!(object instanceof JSONArray)) {
return (JSONArray) object;
}
else {
throw JSON.typeMismatch(name, object, "JSONArray"); throw JSON.typeMismatch(name, object, "JSONArray");
} }
return (JSONArray) object;
} }
/** /**
@ -625,12 +623,10 @@ public class JSONObject {
*/ */
public JSONObject getJSONObject(String name) throws JSONException { public JSONObject getJSONObject(String name) throws JSONException {
Object object = get(name); Object object = get(name);
if (object instanceof JSONObject) { if (!(object instanceof JSONObject)) {
return (JSONObject) object;
}
else {
throw JSON.typeMismatch(name, object, "JSONObject"); throw JSON.typeMismatch(name, object, "JSONObject");
} }
return (JSONObject) object;
} }
/** /**

@ -549,15 +549,13 @@ public class JSONTokener {
if (hex >= '0' && hex <= '9') { if (hex >= '0' && hex <= '9') {
return hex - '0'; return hex - '0';
} }
else if (hex >= 'A' && hex <= 'F') { if (hex >= 'A' && hex <= 'F') {
return hex - 'A' + 10; return hex - 'A' + 10;
} }
else if (hex >= 'a' && hex <= 'f') { if (hex >= 'a' && hex <= 'f') {
return hex - 'a' + 10; return hex - 'a' + 10;
} }
else {
return -1; return -1;
} }
}
} }

Loading…
Cancel
Save