Inline redundant if statements

See gh-39259
This commit is contained in:
Tobias Lippert 2024-01-21 18:42:27 +01:00 committed by Phillip Webb
parent 9cdd0c3776
commit def7523398
18 changed files with 24 additions and 76 deletions

View File

@ -291,9 +291,7 @@ public class BomPlugin implements Plugin<Project> {
if ((node.name() instanceof QName qname) && name.equals(qname.getLocalPart())) { if ((node.name() instanceof QName qname) && name.equals(qname.getLocalPart())) {
return true; return true;
} }
if (name.equals(node.name())) { return name.equals(node.name());
return true;
}
} }
return false; return false;
} }

View File

@ -58,10 +58,7 @@ abstract class AbstractDependencyVersion implements DependencyVersion {
return false; return false;
} }
AbstractDependencyVersion other = (AbstractDependencyVersion) obj; AbstractDependencyVersion other = (AbstractDependencyVersion) obj;
if (!this.comparableVersion.equals(other.comparableVersion)) { return this.comparableVersion.equals(other.comparableVersion);
return false;
}
return true;
} }
@Override @Override

View File

@ -127,10 +127,7 @@ final class ReleaseTrainDependencyVersion implements DependencyVersion {
return false; return false;
} }
ReleaseTrainDependencyVersion other = (ReleaseTrainDependencyVersion) obj; ReleaseTrainDependencyVersion other = (ReleaseTrainDependencyVersion) obj;
if (!this.original.equals(other.original)) { return this.original.equals(other.original);
return false;
}
return true;
} }
@Override @Override

View File

@ -100,10 +100,7 @@ public class CheckClasspathForProhibitedDependencies extends DefaultTask {
if (group.equals("org.apache.geronimo.specs")) { if (group.equals("org.apache.geronimo.specs")) {
return true; return true;
} }
if (group.equals("com.sun.activation")) { return group.equals("com.sun.activation");
return true;
}
return false;
} }
} }

View File

@ -65,11 +65,9 @@ public class CloudFoundryWebEndpointDiscoverer extends WebEndpointDiscoverer {
@Override @Override
protected boolean isExtensionTypeExposed(Class<?> extensionBeanType) { protected boolean isExtensionTypeExposed(Class<?> extensionBeanType) {
if (isHealthEndpointExtension(extensionBeanType) && !isCloudFoundryHealthEndpointExtension(extensionBeanType)) { // Filter regular health endpoint extensions so a CF version can replace them
// Filter regular health endpoint extensions so a CF version can replace them return !isHealthEndpointExtension(extensionBeanType)
return false; || isCloudFoundryHealthEndpointExtension(extensionBeanType);
}
return true;
} }
private boolean isHealthEndpointExtension(Class<?> extensionBeanType) { private boolean isHealthEndpointExtension(Class<?> extensionBeanType) {

View File

@ -136,9 +136,7 @@ public final class EndpointRequest {
return true; return true;
} }
String managementContextId = applicationContext.getParent().getId() + ":management"; String managementContextId = applicationContext.getParent().getId() + ":management";
if (!managementContextId.equals(applicationContext.getId())) { return !managementContextId.equals(applicationContext.getId());
return true;
}
} }
return false; return false;
} }

View File

@ -39,10 +39,7 @@ class WebDriverContextCustomizer implements ContextCustomizer {
if (obj == this) { if (obj == this) {
return true; return true;
} }
if (obj == null || obj.getClass() != getClass()) { return obj != null && obj.getClass() == getClass();
return false;
}
return true;
} }
@Override @Override

View File

@ -119,9 +119,7 @@ public class ResetMocksTestExecutionListener extends AbstractTestExecutionListen
String factoryBeanName = BeanFactory.FACTORY_BEAN_PREFIX + name; String factoryBeanName = BeanFactory.FACTORY_BEAN_PREFIX + name;
if (beanFactory.containsBean(factoryBeanName)) { if (beanFactory.containsBean(factoryBeanName)) {
FactoryBean<?> factoryBean = (FactoryBean<?>) beanFactory.getBean(factoryBeanName); FactoryBean<?> factoryBean = (FactoryBean<?>) beanFactory.getBean(factoryBeanName);
if (!factoryBean.isSingleton()) { return factoryBean.isSingleton();
return false;
}
} }
return true; return true;
} }

View File

@ -81,10 +81,7 @@ public class HelpCommand extends AbstractCommand {
} }
private boolean isHelpShown(Command command) { private boolean isHelpShown(Command command) {
if (command instanceof HelpCommand || command instanceof HintCommand) { return !(command instanceof HelpCommand) && !(command instanceof HintCommand);
return false;
}
return true;
} }
@Override @Override

View File

@ -157,10 +157,7 @@ public final class Metadata {
if (this.deprecation == null && itemMetadata.getDeprecation() != null) { if (this.deprecation == null && itemMetadata.getDeprecation() != null) {
return false; return false;
} }
if (this.deprecation != null && !this.deprecation.equals(itemMetadata.getDeprecation())) { return this.deprecation == null || this.deprecation.equals(itemMetadata.getDeprecation());
return false;
}
return true;
} }
public MetadataItemCondition ofType(Class<?> dataType) { public MetadataItemCondition ofType(Class<?> dataType) {
@ -348,10 +345,7 @@ public final class Metadata {
if (this.value != null && !this.value.equals(valueHint.getValue())) { if (this.value != null && !this.value.equals(valueHint.getValue())) {
return false; return false;
} }
if (this.description != null && !this.description.equals(valueHint.getDescription())) { return this.description == null || this.description.equals(valueHint.getDescription());
return false;
}
return true;
} }
} }

View File

@ -85,11 +85,8 @@ class PropertyMigration {
if (replacementType.equals(currentType)) { if (replacementType.equals(currentType)) {
return true; return true;
} }
if (replacementType.equals(Duration.class.getName()) return replacementType.equals(Duration.class.getName())
&& (currentType.equals(Long.class.getName()) || currentType.equals(Integer.class.getName()))) { && (currentType.equals(Long.class.getName()) || currentType.equals(Integer.class.getName()));
return true;
}
return false;
} }
private static String determineType(ConfigurationMetadataProperty metadata) { private static String determineType(ConfigurationMetadataProperty metadata) {

View File

@ -90,12 +90,9 @@ final class ConfigurationPropertiesCharSequenceToObjectConverter implements Cond
return true; return true;
} }
} }
if ((targetType.isArray() || targetType.isCollection()) && !targetType.equals(BYTE_ARRAY)) { // StringToArrayConverter / StringToCollectionConverter are better than
// StringToArrayConverter / StringToCollectionConverter are better than // ObjectToArrayConverter / ObjectToCollectionConverter
// ObjectToArrayConverter / ObjectToCollectionConverter return (targetType.isArray() || targetType.isCollection()) && !targetType.equals(BYTE_ARRAY);
return true;
}
return false;
} }
@Override @Override

View File

@ -332,10 +332,7 @@ public class ServletContextInitializerBeans extends AbstractCollection<ServletCo
&& this.seen.getOrDefault(type, Collections.emptySet()).contains(object)) { && this.seen.getOrDefault(type, Collections.emptySet()).contains(object)) {
return true; return true;
} }
if (this.seen.getOrDefault(ServletContextInitializer.class, Collections.emptySet()).contains(object)) { return this.seen.getOrDefault(ServletContextInitializer.class, Collections.emptySet()).contains(object);
return true;
}
return false;
} }
static Seen empty() { static Seen empty() {

View File

@ -155,10 +155,7 @@ class EmbeddedServerContainerInvocationContextProvider
if (parameterContext.getParameter().getType().equals(AbstractApplicationLauncher.class)) { if (parameterContext.getParameter().getType().equals(AbstractApplicationLauncher.class)) {
return true; return true;
} }
if (parameterContext.getParameter().getType().equals(RestTemplate.class)) { return parameterContext.getParameter().getType().equals(RestTemplate.class);
return true;
}
return false;
} }
@Override @Override

View File

@ -69,9 +69,7 @@ class SampleLiquibaseApplicationTests {
}; };
if (nested.contains(ConnectException.class)) { if (nested.contains(ConnectException.class)) {
Throwable root = nested.getRootCause(); Throwable root = nested.getRootCause();
if (root.getMessage().contains("Connection refused")) { return root.getMessage().contains("Connection refused");
return true;
}
} }
return false; return false;
} }

View File

@ -55,10 +55,7 @@ public class Location {
if (this.x != location.x) { if (this.x != location.x) {
return false; return false;
} }
if (this.y != location.y) { return this.y == location.y;
return false;
}
return true;
} }
@Override @Override

View File

@ -55,10 +55,7 @@ public class Location {
if (this.x != location.x) { if (this.x != location.x) {
return false; return false;
} }
if (this.y != location.y) { return this.y == location.y;
return false;
}
return true;
} }
@Override @Override

View File

@ -55,10 +55,7 @@ public class Location {
if (this.x != location.x) { if (this.x != location.x) {
return false; return false;
} }
if (this.y != location.y) { return this.y == location.y;
return false;
}
return true;
} }
@Override @Override