1

I'm a Java software developer and often inherit existing projects. These projects follow the convention that each class has an interface even if there is only one implementation.

I would like to merge the interface and the implementation. Does anyone know a tool that supports this merge for a given source folder. The tool may have some flaws but it should automate most of the work. It is ok to adjust a few things afterwards manually.

Here is an example. There is a file MyService.java for the interface:

package my.package;

/**
 * some comment on the interface
 */
public interface MyService {
    /**
     * another comment on the interface
     */
    Object doSomething();
}

and the implementation file MyServiceImpl.java

package my.package;

public class MyServiceImpl implements MyService {
    @Override
    public Object doSomething() {
        //the implementation
    }

    private void doSomethingElse() {
        ....
    }
}

I would like the tool to replace MyService.java with

package my.package;

/**
 * some comment on the interface
 */
public class MyService {
    /**
     * another comment on the interface
     */
    public Object doSomething() {
        //the implementation
    }

    private void doSomethingElse() {
        ....
    }
}

and replace MyServiceImpl in all other files with MyService.

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.