gr.uom.java.xmi.decomposition.replacement.MergeVariableReplacement Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of refactoring-miner Show documentation
Show all versions of refactoring-miner Show documentation
RefactoringMiner is a library/API written in Java that can detect refactorings applied in the history of a Java project.
package gr.uom.java.xmi.decomposition.replacement;
import java.util.LinkedHashSet;
import java.util.Set;
public class MergeVariableReplacement extends Replacement {
private Set mergedVariables;
public MergeVariableReplacement(Set mergedVariables, String newVariable) {
super(mergedVariables.toString(), newVariable, ReplacementType.MERGE_VARIABLES);
this.mergedVariables = mergedVariables;
}
public Set getMergedVariables() {
return mergedVariables;
}
public boolean equal(MergeVariableReplacement other) {
return this.getAfter().equals(other.getAfter()) &&
this.mergedVariables.containsAll(other.mergedVariables) &&
other.mergedVariables.containsAll(this.mergedVariables);
}
public boolean commonAfter(MergeVariableReplacement other) {
Set interestion = new LinkedHashSet(this.mergedVariables);
interestion.retainAll(other.mergedVariables);
return this.getAfter().equals(other.getAfter()) && interestion.size() == 0;
}
public boolean subsumes(MergeVariableReplacement other) {
return this.getAfter().equals(other.getAfter()) &&
this.mergedVariables.containsAll(other.mergedVariables) &&
this.mergedVariables.size() > other.mergedVariables.size();
}
}