I would like to be able to convert code that is calling new Object to a Factory method perhaps in ChangeMethodTargetToStatic.
Here's an example of one of the conversions I'd like to see:
MyCustomLogger logger = new MyCustomLogger(MyClass.class);
That I want to convert to proper SLF4J loggers so it would be:
Logger logger = LoggerFactory.getLogger(MyClass.class);
I tried the following but it didn't change anything:
---
type: specs.openrewrite.org/v1beta/recipe
name: com.difrango.ChangeSimpleTrace
displayName: Change method target to static example
recipeList:
- org.openrewrite.java.ChangeMethodTargetToStatic:
methodPattern: com.difrango.MyCustomLogger <constructor>(Class)
fullyQualifiedTargetTypeName: org.slf4j.LoggerFactory
returnType: org.slf4j.Logger
I would like to be able to convert code that is calling
new Objectto a Factory method perhaps in ChangeMethodTargetToStatic.Here's an example of one of the conversions I'd like to see:
That I want to convert to proper SLF4J loggers so it would be:
I tried the following but it didn't change anything: