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())) {
return true;
}
if (name.equals(node.name())) {
return true;
}
return name.equals(node.name());
}
return false;
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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