项目结构变更
This commit is contained in:
@@ -0,0 +1,95 @@
|
||||
package com.codechecker.model;
|
||||
|
||||
/**
|
||||
* 字段级 diff 结果,用于通知中的 [新增]/[删除]/[修改]/[重命名] 行。
|
||||
*/
|
||||
public class FieldChange {
|
||||
/** 字段变更种类 */
|
||||
public enum ChangeKind {
|
||||
ADDED, REMOVED, MODIFIED, RENAMED
|
||||
}
|
||||
|
||||
private final ChangeKind kind;
|
||||
private final String fieldName;
|
||||
private final String oldFieldName;
|
||||
private final String description;
|
||||
private final String oldType;
|
||||
private final String newType;
|
||||
private final String oldDescription;
|
||||
private final String detail;
|
||||
|
||||
private FieldChange(ChangeKind kind, String fieldName, String oldFieldName, String description,
|
||||
String oldType, String newType, String oldDescription, String detail) {
|
||||
this.kind = kind;
|
||||
this.fieldName = fieldName;
|
||||
this.oldFieldName = oldFieldName;
|
||||
this.description = description;
|
||||
this.oldType = oldType;
|
||||
this.newType = newType;
|
||||
this.oldDescription = oldDescription;
|
||||
this.detail = detail;
|
||||
}
|
||||
|
||||
/** 构造新增字段变更 */
|
||||
public static FieldChange added(FieldInfo field) {
|
||||
return new FieldChange(ChangeKind.ADDED, field.getName(), null, field.getDescription(),
|
||||
null, field.getType(), null, null);
|
||||
}
|
||||
|
||||
/** 构造删除字段变更 */
|
||||
public static FieldChange removed(FieldInfo field) {
|
||||
return new FieldChange(ChangeKind.REMOVED, field.getName(), null, field.getDescription(),
|
||||
field.getType(), null, field.getDescription(), null);
|
||||
}
|
||||
|
||||
/** 构造修改字段变更,detail 通常为类型变化描述 */
|
||||
public static FieldChange modified(FieldInfo oldField, FieldInfo newField, String detail) {
|
||||
return new FieldChange(ChangeKind.MODIFIED, newField.getName(), null, newField.getDescription(),
|
||||
oldField.getType(), newField.getType(), oldField.getDescription(), detail);
|
||||
}
|
||||
|
||||
/** 构造字段重命名;类型变化时 detail 为 oldType → newType */
|
||||
public static FieldChange renamed(FieldInfo oldField, FieldInfo newField) {
|
||||
String typeDetail = oldField.getType().equals(newField.getType())
|
||||
? null
|
||||
: oldField.getType() + " → " + newField.getType();
|
||||
return new FieldChange(ChangeKind.RENAMED, newField.getName(), oldField.getName(),
|
||||
newField.getDescription(), oldField.getType(), newField.getType(),
|
||||
oldField.getDescription(), typeDetail);
|
||||
}
|
||||
|
||||
public ChangeKind getKind() {
|
||||
return kind;
|
||||
}
|
||||
|
||||
public String getFieldName() {
|
||||
return fieldName;
|
||||
}
|
||||
|
||||
/** 重命名前的字段名,仅 RENAMED 时有值 */
|
||||
public String getOldFieldName() {
|
||||
return oldFieldName;
|
||||
}
|
||||
|
||||
/** 变更后的字段说明(通知「说明」段) */
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public String getOldType() {
|
||||
return oldType;
|
||||
}
|
||||
|
||||
public String getNewType() {
|
||||
return newType;
|
||||
}
|
||||
|
||||
public String getOldDescription() {
|
||||
return oldDescription;
|
||||
}
|
||||
|
||||
/** 结构性变更详情,重命名时为类型变化描述 */
|
||||
public String getDetail() {
|
||||
return detail;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user