Skip to content

Rewrite calls from deprecated API to target API #5534

@mipo256

Description

@mipo256

What problem are you trying to solve?

Certain API got deprecated in favor of something new. There is a replacement, and we need to define the rules on how old, deprecated API calls are transitioned into a new call, that is open to discussion

What precondition(s) should be checked before applying this recipe?

We have calls to an old API. The old API produces the type A. The old API produces also either the type A, or any of its children. So it is backward compatible on the source code level. But the input parameters are either changed, or more qualified, or re-arranged or etc.

Describe the situation before applying the recipe

class A {

    void foo(String a, String b) {
        bar(a, b);
    }
    
    /**
     * @deprecated in favor of #bar(Integer, Boolean)
     */
    @Deprecated
    void bar(Integer int, String value) {
    }

    void bar(Integer int, Boolean value) {
    }
}

Describe the situation after applying the recipe

class A {

    void foo(String a, String b) {
        bar(a, Boolean.valueOf(b));
    }
    
    /**
     * @deprecated in favor of #bar(Integer, Boolean)
     */
    @Deprecated
    void bar(Integer int, String value) {
    }

    void bar(Integer int, Boolean value) {
    }
}

Have you considered any alternatives or workarounds?

Based on documentation, there are no workarounds to this in openrewrite, yet.

Any additional context

Are you interested in contributing this recipe to OpenRewrite?

Yes, I would like to

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions