Class NullCheckToOptionalOfNullable
java.lang.Object
eu.solven.cleanthat.engine.java.refactorer.AJavaparserAstMutator
eu.solven.cleanthat.engine.java.refactorer.AJavaparserNodeMutator
eu.solven.cleanthat.engine.java.refactorer.AJavaparserStmtMutator
eu.solven.cleanthat.engine.java.refactorer.mutators.NullCheckToOptionalOfNullable
- All Implemented Interfaces:
ICountMutatorIssues
,IJavaparserAstMutator
,IJavaparserNodeMutator
,IMutator
,IMutatorExternalReferences
,IWalkingMutator<com.github.javaparser.ast.Node,
com.github.javaparser.ast.Node>
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
-
Field Summary
Fields inherited from interface eu.solven.cleanthat.engine.java.refactorer.meta.IMutator
ID_NOOP, IS_PRODUCTION_READY
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetTags()
protected boolean
processStatement
(NodeAndSymbolSolver<com.github.javaparser.ast.stmt.Statement> stmt) Methods inherited from class eu.solven.cleanthat.engine.java.refactorer.AJavaparserStmtMutator
processNotRecursively, replaceStatement
Methods inherited from class eu.solven.cleanthat.engine.java.refactorer.AJavaparserNodeMutator
cancelDueToComment, getNbRemoveIssues, getNbReplaceIssues, isMethodReturnUsed, logJavaParserIssue, onMethodName, optResolved, replaceNode, tryRemove, tryReplace, tryReplace
Methods inherited from class eu.solven.cleanthat.engine.java.refactorer.AJavaparserAstMutator
getNbIdempotencyIssues, messageForIssueReporting, simulateOnClone, walkAst
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface eu.solven.cleanthat.engine.java.refactorer.meta.IMutator
getId, getIds, isDraft, isJreOnly
Methods inherited from interface eu.solven.cleanthat.engine.java.refactorer.meta.IMutatorExternalReferences
checkstyleUrl, errorProneUrl, getCheckstyleId, getCleanthatId, getErrorProneId, getJSparrowId, getLegacyIds, getPmdId, getPmdIds, getSeeUrls, getSonarId, getSpotBugsId, jSparrowUrl, pmdUrl, sonarUrl, spotBugsUrl
Methods inherited from interface eu.solven.cleanthat.engine.java.refactorer.meta.IWalkingMutator
walkAstHasChanged
-
Constructor Details
-
NullCheckToOptionalOfNullable
public NullCheckToOptionalOfNullable()
-
-
Method Details
-
minimalJavaVersion
-
getTags
-
processStatement
protected boolean processStatement(NodeAndSymbolSolver<com.github.javaparser.ast.stmt.Statement> stmt) - Overrides:
processStatement
in classAJavaparserStmtMutator
-