in og/shared/src/main/java/com/google/idea/blaze/common/vcs/WorkspaceFileChange.java [21:60]
public record WorkspaceFileChange(Operation operation, Path workspaceRelativePath) {
/** Type of change that affected the file. */
public enum Operation {
DELETE,
ADD,
MODIFY,
}
/**
* Invert this change. For an add, returns a corresponding delete, and for a delete returns a
* corresponding add. For a modify, return this.
*
* <p>This is used when performing delta updates to correctly handle files that have been
* reverted, i.e. are no longer in the working set.
*/
public WorkspaceFileChange invert() {
return switch (operation) {
case DELETE -> new WorkspaceFileChange(Operation.ADD, workspaceRelativePath);
case ADD -> new WorkspaceFileChange(Operation.DELETE, workspaceRelativePath);
case MODIFY -> this;
};
}
@Override
public String toString() {
return "WorkspaceFileChange{" + operation + ' ' + workspaceRelativePath + '}';
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof WorkspaceFileChange that)) {
return false;
}
return operation == that.operation && workspaceRelativePath.equals(that.workspaceRelativePath);
}
}