Class ValueToConfigurationProperties
- java.lang.Object
-
- org.openrewrite.AbstractSourceVisitor<T>
-
- org.openrewrite.AbstractRefactorVisitor<org.openrewrite.java.tree.J>
-
- org.openrewrite.java.JavaRefactorVisitor
-
- org.openrewrite.java.spring.boot2.ValueToConfigurationProperties
-
- All Implemented Interfaces:
org.openrewrite.java.JavaSourceVisitor<org.openrewrite.java.tree.J>,org.openrewrite.RefactorVisitor<org.openrewrite.java.tree.J>,org.openrewrite.SourceVisitor<org.openrewrite.java.tree.J>
public class ValueToConfigurationProperties extends org.openrewrite.java.JavaRefactorVisitorNotes on ValueToConfigurationProperties1. Scanning phase: Visit class fields, constructors for @Value annotations create a tree of @Value annotation contents. Given @Values containing these property paths: app.config.bar, app.config.foo, screen.resolution.horizontal, screen.resolution.vertical, screen.refresh-rate The resulting tree should be:
root / \ app screen / / \ config resolution refreshRate / / \ bar horizontal verticalStore list of classes where every field is @Value annotated as it can be reused instead of generating a new class Store a list of any existing @ConfigurationProperties classes Record list of fields whose names don't match the last piece of their @Value annotations. Leaf nodes of tree have links back to their original appearance(s)1.b.: Config Class Generation: For each subtree where there is not an existing ConfigurationProperties class, create a new (empty) ConfigurationProperties class Any new classes should be placed adjacent in the source tree to the Spring Application class
2. Config Class Update Phase: Go through the config classes and create fields, getters, setters, corresponding to each node of the tree
3. Reference Update phase: Go through ALL classes and anywhere anything @Value annotated appears, replace it with the corresponding @ConfigurationProperties type. May involve collapsing multiple arguments into a single argument, updating references to those arguments
-
-
Constructor Summary
Constructors Constructor Description ValueToConfigurationProperties()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Collection<org.openrewrite.SourceFile>generate()org.openrewrite.java.tree.JvisitClassDecl(org.openrewrite.java.tree.J.ClassDecl classDecl)org.openrewrite.java.tree.JvisitCompilationUnit(org.openrewrite.java.tree.J.CompilationUnit cu)-
Methods inherited from class org.openrewrite.java.JavaRefactorVisitor
addImport, maybeAddImport, maybeAddImport, maybeRemoveImport, maybeRemoveImport, maybeUnwrapParentheses, visitAnnotatedType, visitAnnotation, visitArrayAccess, visitArrayType, visitAssert, visitAssign, visitAssignOp, visitBinary, visitBlock, visitBreak, visitCase, visitCatch, visitContinue, visitDoWhileLoop, visitElse, visitEmpty, visitEnumValue, visitEnumValueSet, visitFieldAccess, visitFinally, visitForEachLoop, visitForLoop, visitIdentifier, visitIf, visitImport, visitInstanceOf, visitLabel, visitLambda, visitLiteral, visitMemberReference, visitMethod, visitMethodInvocation, visitMultiCatch, visitMultiVariable, visitNewArray, visitNewClass, visitPackage, visitParameterizedType, visitParentheses, visitPrimitive, visitReturn, visitStatement, visitSwitch, visitSynchronized, visitTernary, visitThrow, visitTry, visitTypeCast, visitTypeName, visitTypeParameter, visitTypeParameters, visitUnary, visitUnparsedSource, visitVariable, visitWhileLoop, visitWildcard
-
Methods inherited from class org.openrewrite.AbstractRefactorVisitor
andThen, andThen, next, refactor, refactor, refactor
-
Methods inherited from class org.openrewrite.AbstractSourceVisitor
getCursor, setCursoringOn, visit, visitAfter, visitAfter
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
-
-
Method Detail
-
visitCompilationUnit
public org.openrewrite.java.tree.J visitCompilationUnit(org.openrewrite.java.tree.J.CompilationUnit cu)
- Specified by:
visitCompilationUnitin interfaceorg.openrewrite.java.JavaSourceVisitor<org.openrewrite.java.tree.J>- Overrides:
visitCompilationUnitin classorg.openrewrite.java.JavaRefactorVisitor
-
visitClassDecl
public org.openrewrite.java.tree.J visitClassDecl(org.openrewrite.java.tree.J.ClassDecl classDecl)
- Specified by:
visitClassDeclin interfaceorg.openrewrite.java.JavaSourceVisitor<org.openrewrite.java.tree.J>- Overrides:
visitClassDeclin classorg.openrewrite.java.JavaRefactorVisitor
-
generate
public java.util.Collection<org.openrewrite.SourceFile> generate()
-
-