Class JPMMLVisitor


  • public class JPMMLVisitor
    extends org.openrewrite.java.JavaVisitor<org.openrewrite.ExecutionContext>
    • Field Summary

      • Fields inherited from class org.openrewrite.java.JavaVisitor

        javadocVisitor
    • 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.ClassDeclaration addMissingMethod​(org.openrewrite.java.tree.J.ClassDeclaration classDecl, java.lang.String searchedMethod, org.openrewrite.java.JavaTemplate javaTemplate)
      Add a J.MethodDeclaration to the given J.ClassDeclaration if the latter does not contain the searchedMethod, otherwise it does nothing
      protected java.util.Optional<org.kie.openrewrite.recipe.jpmml.JPMMLVisitor.RemovedListTupla> getRemovedListTupla​(org.openrewrite.java.tree.J.NewClass toCheck)
      Return Optional<RemovedListTupla> if the given J.NewClass constructor has not the List anymore Optional.empty() otherwise
      protected boolean hasFieldNameImport​(org.openrewrite.java.tree.J.CompilationUnit toCheck)
      Return true if the given J.CompilationUnit contains an {@see #FIELD_NAME_FQDN} import, false otherwise
      protected boolean hasFieldNameParameter​(org.openrewrite.java.tree.J.MethodInvocation toCheck)
      Return true if the given J.MethodInvocation is FieldName.create(...), false otherwise
      protected boolean isFieldNameCreate​(org.openrewrite.java.tree.J.MethodInvocation toCheck)
      Return true if the given J.MethodInvocation is FieldName.create(...), false otherwise
      protected boolean isFieldNameGetNameToGetFieldMapped​(org.openrewrite.java.tree.J.MethodInvocation toCheck)
      Return true if the given J.MethodInvocation is #FieldName(_any_).getName(...), and the modified method is String(_any_).getField(...) false otherwise.
      protected boolean isFieldNameImport​(org.openrewrite.java.tree.J.Import toCheck)
      Return true if the given J.Import is {@see #FIELD_NAME_FQDN}, false otherwise
      protected boolean methodExists​(org.openrewrite.java.tree.J.ClassDeclaration toCheck, java.lang.String searchedMethod)
      Return true if the given J.ClassDeclaration contains the searchedMethod, false otherwise
      protected org.openrewrite.java.tree.J.CompilationUnit removeFieldNameImport​(org.openrewrite.java.tree.J.CompilationUnit cu)
      Remove the {@see #FIELD_NAME_FQDN} import from the given J.CompilationUnit, if present
      protected org.openrewrite.java.tree.Expression replaceInstantiation​(org.openrewrite.java.tree.J.NewClass newClass)  
      protected org.openrewrite.java.tree.Expression replaceInstantiationListRemoved​(org.openrewrite.java.tree.J.NewClass newClass)
      Returns a new J.NewClass with the originalInstantiatedType replaced by targetInstantiatedType, if present.
      protected org.openrewrite.java.tree.J.NewClass replaceOriginalToTargetInstantiation​(org.openrewrite.java.tree.J.NewClass newClass)
      Returns a new J.NewClass with the originalInstantiatedType replaced by targetInstantiatedType, if present.
      protected boolean toMigrate​(java.util.List<org.openrewrite.java.tree.J.Import> imports)  
      protected org.openrewrite.java.tree.JavaType.Method updateMethodToTargetInstantiatedType​(org.openrewrite.java.tree.JavaType.Method oldMethodType)  
      protected org.openrewrite.java.tree.TypeTree updateTypeTreeToTargetInstantiatedType​(org.openrewrite.java.tree.J.NewClass newClass)  
      protected boolean useFieldNameGetValue​(org.openrewrite.java.tree.J.MethodInvocation toCheck)
      Return true if the given J.MethodInvocation invokes (_field_).getValue(), false otherwise
      org.openrewrite.java.tree.J visitBinary​(org.openrewrite.java.tree.J.Binary binary, org.openrewrite.ExecutionContext executionContext)  
      org.openrewrite.java.tree.J.ClassDeclaration visitClassDeclaration​(org.openrewrite.java.tree.J.ClassDeclaration classDecl, org.openrewrite.ExecutionContext executionContext)  
      org.openrewrite.java.tree.J.CompilationUnit visitCompilationUnit​(org.openrewrite.java.tree.J.CompilationUnit cu, org.openrewrite.ExecutionContext executionContext)  
      org.openrewrite.java.tree.J visitMethodInvocation​(org.openrewrite.java.tree.J.MethodInvocation method, org.openrewrite.ExecutionContext executionContext)  
      org.openrewrite.java.tree.J visitNewClass​(org.openrewrite.java.tree.J.NewClass newClass, org.openrewrite.ExecutionContext executionContext)  
      org.openrewrite.java.tree.J.VariableDeclarations.NamedVariable visitVariable​(org.openrewrite.java.tree.J.VariableDeclarations.NamedVariable variable, org.openrewrite.ExecutionContext executionContext)  
      org.openrewrite.java.tree.J.VariableDeclarations visitVariableDeclarations​(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
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • JPMMLVisitor

        public JPMMLVisitor​(java.lang.String oldInstantiatedFullyQualifiedTypeName,
                            java.lang.String newInstantiatedFullyQualifiedTypeName)
    • Method Detail

      • visitBinary

        public org.openrewrite.java.tree.J visitBinary​(org.openrewrite.java.tree.J.Binary binary,
                                                       org.openrewrite.ExecutionContext executionContext)
        Overrides:
        visitBinary in class org.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:
        visitClassDeclaration in class org.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:
        visitCompilationUnit in class org.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:
        visitMethodInvocation in class org.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:
        visitNewClass in class org.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:
        visitVariable in class org.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:
        visitVariableDeclarations in class org.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 given J.CompilationUnit, if present
        Parameters:
        cu -
        Returns:
      • hasFieldNameImport

        protected boolean hasFieldNameImport​(org.openrewrite.java.tree.J.CompilationUnit toCheck)
        Return true if the given J.CompilationUnit contains an {@see #FIELD_NAME_FQDN} import, false otherwise
        Parameters:
        toCheck -
        Returns:
      • isFieldNameImport

        protected boolean isFieldNameImport​(org.openrewrite.java.tree.J.Import toCheck)
        Return true if the given J.Import is {@see #FIELD_NAME_FQDN}, false otherwise
        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 a J.MethodDeclaration to the given J.ClassDeclaration if 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)
        Return true if the given J.ClassDeclaration contains the searchedMethod, false otherwise
        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 new J.NewClass with the originalInstantiatedType replaced by targetInstantiatedType, 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 new J.NewClass with the originalInstantiatedType replaced by targetInstantiatedType, 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)
        Return Optional<RemovedListTupla> if the given J.NewClass constructor has not the List anymore Optional.empty() otherwise
        Parameters:
        toCheck -
        Returns:
      • isFieldNameCreate

        protected boolean isFieldNameCreate​(org.openrewrite.java.tree.J.MethodInvocation toCheck)
        Return true if the given J.MethodInvocation is FieldName.create(...), false otherwise
        Parameters:
        toCheck -
        Returns:
      • hasFieldNameParameter

        protected boolean hasFieldNameParameter​(org.openrewrite.java.tree.J.MethodInvocation toCheck)
        Return true if the given J.MethodInvocation is FieldName.create(...), false otherwise
        Parameters:
        toCheck -
        Returns:
      • isFieldNameGetNameToGetFieldMapped

        protected boolean isFieldNameGetNameToGetFieldMapped​(org.openrewrite.java.tree.J.MethodInvocation toCheck)
        Return true if the given J.MethodInvocation is #FieldName(_any_).getName(...), and the modified method is String(_any_).getField(...) false otherwise. Mapped elements are defined in GET_NAME_TO_GET_FIELD_CLASSES
        Parameters:
        toCheck -
        Returns:
      • useFieldNameGetValue

        protected boolean useFieldNameGetValue​(org.openrewrite.java.tree.J.MethodInvocation toCheck)
        Return true if the given J.MethodInvocation invokes (_field_).getValue(), false otherwise
        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)