Design Partners
Transform calls to Objects.isNull(..) and Objects.nonNull(..)
** org.openrewrite.java.RemoveObjectsIsNull** Replace calls to Objects.isNull(..) and Objects.nonNull(..) with a simple null check. Using these methods outside of stream predicates is not idiomatic.

Source

  • groupId: org.openrewrite
  • artifactId: rewrite-java
  • version: 7.27.1

Usage

This recipe has no required configuration parameters and comes from a rewrite core library. It can be activated directly without adding any dependencies.
Gradle
Maven
build.gradle
plugins {
id("org.openrewrite.rewrite") version("5.26.1")
}
rewrite {
activeRecipe("org.openrewrite.java.RemoveObjectsIsNull")
}
repositories {
mavenCentral()
}
pom.xml
<project>
<build>
<plugins>
<plugin>
<groupId>org.openrewrite.maven</groupId>
<artifactId>rewrite-maven-plugin</artifactId>
<version>4.31.1</version>
<configuration>
<activeRecipes>
<recipe>org.openrewrite.java.RemoveObjectsIsNull</recipe>
</activeRecipes>
</configuration>
</plugin>
</plugins>
</build>
</project>
Recipes can also be activated directly from the command line by adding the argument -Drewrite.activeRecipesorg.openrewrite.java.RemoveObjectsIsNull
Export as PDF
Copy link