Class NullCheckToOptionalOfNullable

All Implemented Interfaces:
ICountMutatorIssues, IJavaparserAstMutator, IJavaparserNodeMutator, IMutator, IMutatorExternalReferences, IWalkingMutator<com.github.javaparser.ast.Node,com.github.javaparser.ast.Node>

public class NullCheckToOptionalOfNullable extends AJavaparserStmtMutator
Turns `if (s != null) {...}` into `Optional.ofNullable(s).ifPresent(...)` BEWARE This case of application should be restricted, as a simple null-check is often simpler than an `Optional.ofNullable`, especially if the `thenStmt` does not depends on the nullable variable.
Author:
Benoit Lacelle
  • Constructor Details

    • NullCheckToOptionalOfNullable

      public NullCheckToOptionalOfNullable()
  • Method Details