All Downloads are FREE. Search and download functionalities are using the official Maven repository.

apidiff.internal.refactor.RefactoringProcessorImpl Maven / Gradle / Ivy

Go to download

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;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy