package com.codechecker.model; /** * Git 扫描得到的单个 Java 模型类变更记录。 */ public class ChangedClassFile { /** Git diff 状态:修改 / 删除 / 重命名 */ public enum ChangeStatus { MODIFIED, DELETED, RENAMED } private final String relativePath; private final String oldRelativePath; private final ChangeStatus status; private final String className; private final String oldClassName; private final ClassType classType; /** 修改或删除(无路径变化) */ public ChangedClassFile(String relativePath, ChangeStatus status, String className, ClassType classType) { this(relativePath, null, status, className, null, classType); } /** 重命名或同路径类名变更 */ public ChangedClassFile(String relativePath, String oldRelativePath, ChangeStatus status, String className, String oldClassName, ClassType classType) { this.relativePath = relativePath; this.oldRelativePath = oldRelativePath; this.status = status; this.className = className; this.oldClassName = oldClassName; this.classType = classType; } /** 新提交中的相对路径 */ public String getRelativePath() { return relativePath; } /** 旧提交中的相对路径,未变路径则为 null */ public String getOldRelativePath() { return oldRelativePath; } /** 读取旧版本源码时使用的路径 */ public String pathForOldCommit() { return oldRelativePath != null ? oldRelativePath : relativePath; } public ChangeStatus getStatus() { return status; } /** 当前简单类名 */ public String getClassName() { return className; } /** 重命名前简单类名 */ public String getOldClassName() { return oldClassName; } public ClassType getClassType() { return classType; } }