apidiff.internal.refactor.RefactoringProcessorImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of apidiff Show documentation
Show all versions of apidiff Show documentation
A tool to identify API breaking and non-breaking changes between two versions of a Java library
The newest version!
package apidiff.internal.refactor;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.eclipse.jgit.lib.Repository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import refdiff.core.RefDiff;
import refdiff.core.api.RefactoringType;
import refdiff.core.rm2.model.refactoring.SDRefactoring;
public class RefactoringProcessorImpl implements RefactorProcessor {
private Logger logger = LoggerFactory.getLogger(RefactoringProcessorImpl.class);
private Map> format(final List refactorings){
Map> result = new HashMap>();
for(SDRefactoring ref : refactorings){
RefactoringType refactoringName = ref.getRefactoringType();
if(result.containsKey(refactoringName)){
result.get(refactoringName).add(ref);
}
else{
List listRefactorings = new ArrayList();
listRefactorings.add(ref);
result.put(refactoringName, listRefactorings);
}
}
return result;
}
@Override
public Map> detectRefactoringAtCommit(final Repository repository, final String commit){
Map> result = new HashMap>();
try{
RefDiff refDiff = new RefDiff();
result = this.format(refDiff.detectAtCommit(repository, commit));
} catch (Exception e) {
this.logger.error("Erro in refactoring process [repository=" + repository + "][commit=" + commit + "]", e);
}
return result;
}
}