Package org.kie.openrewrite.recipe.jpmml
Class JPMMLVisitor
- java.lang.Object
-
- org.openrewrite.TreeVisitor<org.openrewrite.java.tree.J,P>
-
- org.openrewrite.java.JavaVisitor<org.openrewrite.ExecutionContext>
-
- org.kie.openrewrite.recipe.jpmml.JPMMLVisitor
-
public class JPMMLVisitor extends org.openrewrite.java.JavaVisitor<org.openrewrite.ExecutionContext>
-
-
Constructor Summary
Constructors Constructor Description JPMMLVisitor(java.lang.String oldInstantiatedFullyQualifiedTypeName, java.lang.String newInstantiatedFullyQualifiedTypeName)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected org.openrewrite.java.tree.J.ClassDeclarationaddMissingMethod(org.openrewrite.java.tree.J.ClassDeclaration classDecl, java.lang.String searchedMethod, org.openrewrite.java.JavaTemplate javaTemplate)Add aJ.MethodDeclarationto the givenJ.ClassDeclarationif the latter does not contain the searchedMethod, otherwise it does nothingprotected java.util.Optional<org.kie.openrewrite.recipe.jpmml.JPMMLVisitor.RemovedListTupla>getRemovedListTupla(org.openrewrite.java.tree.J.NewClass toCheck)ReturnOptional<RemovedListTupla>if the givenJ.NewClassconstructor has not the List anymoreOptional.empty()otherwiseprotected booleanhasFieldNameImport(org.openrewrite.java.tree.J.CompilationUnit toCheck)Returntrueif the givenJ.CompilationUnitcontains an {@see #FIELD_NAME_FQDN} import,falseotherwiseprotected booleanhasFieldNameParameter(org.openrewrite.java.tree.J.MethodInvocation toCheck)Returntrueif the givenJ.MethodInvocationis FieldName.create(...),falseotherwiseprotected booleanisFieldNameCreate(org.openrewrite.java.tree.J.MethodInvocation toCheck)Returntrueif the givenJ.MethodInvocationis FieldName.create(...),falseotherwiseprotected booleanisFieldNameGetNameToGetFieldMapped(org.openrewrite.java.tree.J.MethodInvocation toCheck)Returntrueif the givenJ.MethodInvocationis #FieldName(_any_).getName(...), and the modified method is String(_any_).getField(...)falseotherwise.protected booleanisFieldNameImport(org.openrewrite.java.tree.J.Import toCheck)Returntrueif the givenJ.Importis {@see #FIELD_NAME_FQDN},falseotherwiseprotected booleanmethodExists(org.openrewrite.java.tree.J.ClassDeclaration toCheck, java.lang.String searchedMethod)Returntrueif the givenJ.ClassDeclarationcontains the searchedMethod,falseotherwiseprotected org.openrewrite.java.tree.J.CompilationUnitremoveFieldNameImport(org.openrewrite.java.tree.J.CompilationUnit cu)Remove the {@see #FIELD_NAME_FQDN} import from the givenJ.CompilationUnit, if presentprotected org.openrewrite.java.tree.ExpressionreplaceInstantiation(org.openrewrite.java.tree.J.NewClass newClass)protected org.openrewrite.java.tree.ExpressionreplaceInstantiationListRemoved(org.openrewrite.java.tree.J.NewClass newClass)Returns a newJ.NewClasswith theoriginalInstantiatedTypereplaced bytargetInstantiatedType, if present.protected org.openrewrite.java.tree.J.NewClassreplaceOriginalToTargetInstantiation(org.openrewrite.java.tree.J.NewClass newClass)Returns a newJ.NewClasswith theoriginalInstantiatedTypereplaced bytargetInstantiatedType, if present.protected booleantoMigrate(java.util.List<org.openrewrite.java.tree.J.Import> imports)protected org.openrewrite.java.tree.JavaType.MethodupdateMethodToTargetInstantiatedType(org.openrewrite.java.tree.JavaType.Method oldMethodType)protected org.openrewrite.java.tree.TypeTreeupdateTypeTreeToTargetInstantiatedType(org.openrewrite.java.tree.J.NewClass newClass)protected booleanuseFieldNameGetValue(org.openrewrite.java.tree.J.MethodInvocation toCheck)Returntrueif the givenJ.MethodInvocationinvokes (_field_).getValue(),falseotherwiseorg.openrewrite.java.tree.JvisitBinary(org.openrewrite.java.tree.J.Binary binary, org.openrewrite.ExecutionContext executionContext)org.openrewrite.java.tree.J.ClassDeclarationvisitClassDeclaration(org.openrewrite.java.tree.J.ClassDeclaration classDecl, org.openrewrite.ExecutionContext executionContext)org.openrewrite.java.tree.J.CompilationUnitvisitCompilationUnit(org.openrewrite.java.tree.J.CompilationUnit cu, org.openrewrite.ExecutionContext executionContext)org.openrewrite.java.tree.JvisitMethodInvocation(org.openrewrite.java.tree.J.MethodInvocation method, org.openrewrite.ExecutionContext executionContext)org.openrewrite.java.tree.JvisitNewClass(org.openrewrite.java.tree.J.NewClass newClass, org.openrewrite.ExecutionContext executionContext)org.openrewrite.java.tree.J.VariableDeclarations.NamedVariablevisitVariable(org.openrewrite.java.tree.J.VariableDeclarations.NamedVariable variable, org.openrewrite.ExecutionContext executionContext)org.openrewrite.java.tree.J.VariableDeclarationsvisitVariableDeclarations(org.openrewrite.java.tree.J.VariableDeclarations multiVariable, org.openrewrite.ExecutionContext executionContext)-
Methods inherited from class org.openrewrite.java.JavaVisitor
autoFormat, autoFormat, autoFormat, describeLocation, getJavadocVisitor, getLanguage, isAcceptable, isInSameNameScope, isInSameNameScope, maybeAddImport, maybeAddImport, maybeAddImport, maybeAddImport, maybeAddImport, maybeAutoFormat, maybeAutoFormat, maybeAutoFormat, maybeRemoveImport, maybeRemoveImport, visitAnnotatedType, visitAnnotation, visitArrayAccess, visitArrayDimension, visitArrayType, visitAssert, visitAssignment, visitAssignmentOperation, visitBlock, visitBreak, visitCase, visitCatch, visitContainer, visitContinue, visitControlParentheses, visitDoWhileLoop, visitElse, visitEmpty, visitEnumValue, visitEnumValueSet, visitExpression, visitFieldAccess, visitForControl, visitForEachControl, visitForEachLoop, visitForLoop, visitIdentifier, visitIf, visitImport, visitInstanceOf, visitJavaSourceFile, visitLabel, visitLambda, visitLeftPadded, visitLiteral, visitMemberReference, visitMethodDeclaration, visitMultiCatch, visitNewArray, visitPackage, visitParameterizedType, visitParentheses, visitPrimitive, visitReturn, visitRightPadded, visitSpace, visitStatement, visitSwitch, visitSwitchExpression, visitSynchronized, visitTernary, visitThrow, visitTry, visitTryResource, visitType, visitTypeCast, visitTypeName, visitTypeParameter, visitUnary, visitWhileLoop, visitWildcard, visitYield
-
Methods inherited from class org.openrewrite.TreeVisitor
adapt, collect, collect, defaultValue, doAfterVisit, doAfterVisit, getAfterVisit, getCursor, isAdaptableTo, noop, postVisit, preVisit, reduce, reduce, reduce, setCursor, visit, visit, visit, visitAndCast, visitAndCast, visitMarker, visitMarkers, visitNonNull, visitNonNull, visitSourceFile
-
-
-
-
Method Detail
-
visitBinary
public org.openrewrite.java.tree.J visitBinary(org.openrewrite.java.tree.J.Binary binary, org.openrewrite.ExecutionContext executionContext)- Overrides:
visitBinaryin classorg.openrewrite.java.JavaVisitor<org.openrewrite.ExecutionContext>
-
visitClassDeclaration
public org.openrewrite.java.tree.J.ClassDeclaration visitClassDeclaration(org.openrewrite.java.tree.J.ClassDeclaration classDecl, org.openrewrite.ExecutionContext executionContext)- Overrides:
visitClassDeclarationin classorg.openrewrite.java.JavaVisitor<org.openrewrite.ExecutionContext>
-
visitCompilationUnit
public org.openrewrite.java.tree.J.CompilationUnit visitCompilationUnit(org.openrewrite.java.tree.J.CompilationUnit cu, org.openrewrite.ExecutionContext executionContext)- Overrides:
visitCompilationUnitin classorg.openrewrite.java.JavaVisitor<org.openrewrite.ExecutionContext>
-
visitMethodInvocation
public org.openrewrite.java.tree.J visitMethodInvocation(org.openrewrite.java.tree.J.MethodInvocation method, org.openrewrite.ExecutionContext executionContext)- Overrides:
visitMethodInvocationin classorg.openrewrite.java.JavaVisitor<org.openrewrite.ExecutionContext>
-
visitNewClass
public org.openrewrite.java.tree.J visitNewClass(org.openrewrite.java.tree.J.NewClass newClass, org.openrewrite.ExecutionContext executionContext)- Overrides:
visitNewClassin classorg.openrewrite.java.JavaVisitor<org.openrewrite.ExecutionContext>
-
visitVariable
public org.openrewrite.java.tree.J.VariableDeclarations.NamedVariable visitVariable(org.openrewrite.java.tree.J.VariableDeclarations.NamedVariable variable, org.openrewrite.ExecutionContext executionContext)- Overrides:
visitVariablein classorg.openrewrite.java.JavaVisitor<org.openrewrite.ExecutionContext>
-
visitVariableDeclarations
public org.openrewrite.java.tree.J.VariableDeclarations visitVariableDeclarations(org.openrewrite.java.tree.J.VariableDeclarations multiVariable, org.openrewrite.ExecutionContext executionContext)- Overrides:
visitVariableDeclarationsin classorg.openrewrite.java.JavaVisitor<org.openrewrite.ExecutionContext>
-
removeFieldNameImport
protected org.openrewrite.java.tree.J.CompilationUnit removeFieldNameImport(org.openrewrite.java.tree.J.CompilationUnit cu)
Remove the {@see #FIELD_NAME_FQDN} import from the givenJ.CompilationUnit, if present- Parameters:
cu-- Returns:
-
hasFieldNameImport
protected boolean hasFieldNameImport(org.openrewrite.java.tree.J.CompilationUnit toCheck)
Returntrueif the givenJ.CompilationUnitcontains an {@see #FIELD_NAME_FQDN} import,falseotherwise- Parameters:
toCheck-- Returns:
-
isFieldNameImport
protected boolean isFieldNameImport(org.openrewrite.java.tree.J.Import toCheck)
Returntrueif the givenJ.Importis {@see #FIELD_NAME_FQDN},falseotherwise- Parameters:
toCheck-- Returns:
-
addMissingMethod
protected org.openrewrite.java.tree.J.ClassDeclaration addMissingMethod(org.openrewrite.java.tree.J.ClassDeclaration classDecl, java.lang.String searchedMethod, org.openrewrite.java.JavaTemplate javaTemplate)Add aJ.MethodDeclarationto the givenJ.ClassDeclarationif the latter does not contain the searchedMethod, otherwise it does nothing- Parameters:
classDecl-searchedMethod-javaTemplate-- Returns:
-
methodExists
protected boolean methodExists(org.openrewrite.java.tree.J.ClassDeclaration toCheck, java.lang.String searchedMethod)Returntrueif the givenJ.ClassDeclarationcontains the searchedMethod,falseotherwise- Parameters:
toCheck-searchedMethod-- Returns:
-
replaceInstantiation
protected org.openrewrite.java.tree.Expression replaceInstantiation(org.openrewrite.java.tree.J.NewClass newClass)
- Parameters:
newClass-- Returns:
-
replaceOriginalToTargetInstantiation
protected org.openrewrite.java.tree.J.NewClass replaceOriginalToTargetInstantiation(org.openrewrite.java.tree.J.NewClass newClass)
Returns a newJ.NewClasswith theoriginalInstantiatedTypereplaced bytargetInstantiatedType, if present. Otherwise, returns the original newClass.- Parameters:
newClass-- Returns:
-
replaceInstantiationListRemoved
protected org.openrewrite.java.tree.Expression replaceInstantiationListRemoved(org.openrewrite.java.tree.J.NewClass newClass)
Returns a newJ.NewClasswith theoriginalInstantiatedTypereplaced bytargetInstantiatedType, if present. Otherwise, returns the original newClass.- Parameters:
newClass-- Returns:
-
getRemovedListTupla
protected java.util.Optional<org.kie.openrewrite.recipe.jpmml.JPMMLVisitor.RemovedListTupla> getRemovedListTupla(org.openrewrite.java.tree.J.NewClass toCheck)
ReturnOptional<RemovedListTupla>if the givenJ.NewClassconstructor has not the List anymoreOptional.empty()otherwise- Parameters:
toCheck-- Returns:
-
isFieldNameCreate
protected boolean isFieldNameCreate(org.openrewrite.java.tree.J.MethodInvocation toCheck)
Returntrueif the givenJ.MethodInvocationis FieldName.create(...),falseotherwise- Parameters:
toCheck-- Returns:
-
hasFieldNameParameter
protected boolean hasFieldNameParameter(org.openrewrite.java.tree.J.MethodInvocation toCheck)
Returntrueif the givenJ.MethodInvocationis FieldName.create(...),falseotherwise- Parameters:
toCheck-- Returns:
-
isFieldNameGetNameToGetFieldMapped
protected boolean isFieldNameGetNameToGetFieldMapped(org.openrewrite.java.tree.J.MethodInvocation toCheck)
Returntrueif the givenJ.MethodInvocationis #FieldName(_any_).getName(...), and the modified method is String(_any_).getField(...)falseotherwise. Mapped elements are defined inGET_NAME_TO_GET_FIELD_CLASSES- Parameters:
toCheck-- Returns:
-
useFieldNameGetValue
protected boolean useFieldNameGetValue(org.openrewrite.java.tree.J.MethodInvocation toCheck)
Returntrueif the givenJ.MethodInvocationinvokes (_field_).getValue(),falseotherwise- Parameters:
toCheck-- Returns:
-
toMigrate
protected boolean toMigrate(java.util.List<org.openrewrite.java.tree.J.Import> imports)
-
updateMethodToTargetInstantiatedType
protected org.openrewrite.java.tree.JavaType.Method updateMethodToTargetInstantiatedType(org.openrewrite.java.tree.JavaType.Method oldMethodType)
-
updateTypeTreeToTargetInstantiatedType
protected org.openrewrite.java.tree.TypeTree updateTypeTreeToTargetInstantiatedType(org.openrewrite.java.tree.J.NewClass newClass)
-
-