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

org.refactoringminer.utils.RefactoringRelationshipGroup Maven / Gradle / Ivy

Go to download

RefactoringMiner is a library/API written in Java that can detect refactorings applied in the history of a Java project.

There is a newer version: 3.0.9
Show newest version
package org.refactoringminer.utils;

import java.util.ArrayList;
import java.util.List;

import org.refactoringminer.api.RefactoringType;

public class RefactoringRelationshipGroup {

  private List refactoringRelationships = new ArrayList<>();

  public RefactoringRelationshipGroup(RefactoringRelationship refactoringRelationship) {
    refactoringRelationships.add(refactoringRelationship);
  }

  public RefactoringType addRefactoringRelationship(RefactoringRelationship r) {
    if (r.getRefactoringType().equals(this.getRefactoringType()) && r.getMainEntity().equals(this.getMainEntity())) {
      refactoringRelationships.add(r);
    }
    throw new IllegalArgumentException(String.format("refactoring relatiships are note from the same group: [] []", r, refactoringRelationships.get(0)));
  }

  public RefactoringType getRefactoringType() {
    return refactoringRelationships.get(0).getRefactoringType();
  }

  public String getMainEntity() {
    return refactoringRelationships.get(0).getMainEntity();
  }

  @Override
  public boolean equals(Object obj) {
    if (obj instanceof RefactoringRelationshipGroup) {
      RefactoringRelationshipGroup other = (RefactoringRelationshipGroup) obj;
      return other.getRefactoringType().equals(this.getRefactoringType()) && other.getMainEntity().equals(this.getMainEntity());
    }
    return false;
  }

  @Override
  public int hashCode() {
    final int prime = 31;
    int result = 1;
    result = prime * result + getMainEntity().hashCode();
    result = prime * result + getRefactoringType().hashCode();
    return result;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy