in camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel44/CamelCoreRecipe.java [81:139]
public TreeVisitor<?, ExecutionContext> getVisitor() {
return RecipesUtil.newVisitor(new AbstractCamelJavaVisitor() {
@Override
protected J.MethodInvocation doVisitMethodInvocation(J.MethodInvocation method, ExecutionContext context) {
J.MethodInvocation mi = super.doVisitMethodInvocation(method, context);
if (getMethodMatcher(M_EXCHANGE_GET_CREATED).matches(mi, false)) {
//add call to getClock before call of getCreated
mi = mi.withName(mi.getName().withSimpleName("getClock().getCreated"));
} else if (getMethodMatcher(M_PROPERTIES_LOOKUP_LOOKUP).matches(mi, false)
&& mi.getArguments().size() == 1) { //without the condition, the recipes is applied again
//add default value null
List<Expression> arguments = new ArrayList<>(mi.getArguments());
arguments.add(RecipesUtil.createNullExpression());
mi = mi.withArguments(arguments);
} else if (getMethodMatcher(M_EXPRESSION_CAUSE_JSONPATH1).matches(mi, false) ||
getMethodMatcher(M_EXPRESSION_CAUSE_JSONPATH2).matches(mi, false) ||
getMethodMatcher(M_EXPRESSION_CAUSE_TOKENIZE1).matches(mi, false) ||
getMethodMatcher(M_EXPRESSION_CAUSE_TOKENIZE2).matches(mi, false) ||
getMethodMatcher(M_EXPRESSION_CAUSE_TOKENIZE3).matches(mi, false) ||
getMethodMatcher(M_EXPRESSION_CAUSE_XPATH1).matches(mi, false) ||
getMethodMatcher(M_EXPRESSION_CAUSE_XPATH2).matches(mi, false) ||
getMethodMatcher(M_EXPRESSION_CAUSE_XPATH3).matches(mi, false) ||
getMethodMatcher(M_EXPRESSION_CAUSE_XQUERY1).matches(mi, false) ||
getMethodMatcher(M_EXPRESSION_CAUSE_XQUERY2).matches(mi, false) ||
getMethodMatcher(M_EXPRESSION_CAUSE_XQUERY3).matches(mi, false)) {
mi = mi.withName(
RecipesUtil.createIdentifier(Space.EMPTY, "removed_" + mi.getSimpleName(), mi.getType().toString()))
.withComments(Collections.singletonList(RecipesUtil.createMultinlineComment(
"Some Java DSL for tokenize, xmlTokenize, xpath, xquery and jsonpath has been removed as part of making the DSL model consistent.\n"
+
"See https://camel.apache.org/manual/camel-4x-upgrade-guide-4_4.html#_camel_core for more details.\n")));
}
return mi;
}
@Override
protected J.NewClass doVisitNewClass(J.NewClass newClass, ExecutionContext context) {
J.NewClass nc = super.doVisitNewClass(newClass, context);
//can not use org.openrewrite.java.DeleteMethodArgument, because it doesn't modify calls of constructors
if ((getMethodMatcher(CONST_STOP_WATCH_LONG01).matches(nc)
|| getMethodMatcher(CONST_STOP_WATCH_LONG02).matches(nc))
&& nc.getArguments().size() == 1) { //without the condition, the recipes is applied againorg.openrewrite.properties.ChangePropertyKey
nc = nc.withArguments(Collections.emptyList()).withComments(Collections.singletonList(RecipesUtil
.createMultinlineComment(
"Removed the deprecated constructor from the internal class org.apache.camel.util.StopWatch.\n"
+
"Users of this class are advised to use the default constructor if necessary.Changed exception thrown from IOException to Exception.\n")));
}
return nc;
}
});
}