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

org.refactoringminer.utils.RefactoringCrawlerRefactoring 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.HashMap;
import java.util.Map;

import org.refactoringminer.api.RefactoringType;

public class RefactoringCrawlerRefactoring {

  private static final Map TYPE_MAP;
  static {
    TYPE_MAP = new HashMap<>();
    TYPE_MAP.put("RenamedClasses", RefactoringType.RENAME_CLASS);
    TYPE_MAP.put("RenamedMethods", RefactoringType.RENAME_METHOD);
    TYPE_MAP.put("PulledUpMethods", RefactoringType.PULL_UP_OPERATION);
    TYPE_MAP.put("PushedDownMethods", RefactoringType.PUSH_DOWN_OPERATION);
    TYPE_MAP.put("MovedMethods", RefactoringType.MOVE_OPERATION);
    //TYPE_MAP.put("ChangedMethodSignatures", RefactoringType.CHANGE_METHOD_SIGNATURE);
    TYPE_MAP.put("RenamedPackages", RefactoringType.RENAME_PACKAGE);
  }

  private String type;
  private String newElement;
  private String oldElement;
  
  public RefactoringCrawlerRefactoring(String type, String newElement, String oldElement) {
    this.type = type.trim();
    this.newElement = newElement.trim();
    this.oldElement = oldElement.trim();
  }

  public String getType() {
    return type;
  }

  public String getNewElement() {
    return newElement;
  }

  public String getOldElement() {
    return oldElement;
  }
  
  @Override
  public String toString() {
    return type + '\t' + oldElement + '\t' + newElement;
  }

  RefactoringRelationship toRefactoringRelationship() {
    RefactoringType refType = TYPE_MAP.get(type);
    if (refType == null) {
      throw new RuntimeException("unkown refactoring type " + type);
    }
    return new RefactoringRelationship(refType, oldElement, newElement);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy