Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
141 changes: 141 additions & 0 deletions gitlab4j-models/src/main/java/org/gitlab4j/api/models/LineRange.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
/*
* LineRange.java
* Copyright 2025 Qunhe Tech, all rights reserved.
* Qunhe PROPRIETARY/CONFIDENTIAL, any form of usage is subject to approval.
*/

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove this header?

package org.gitlab4j.api.models;

import java.io.Serializable;

import org.gitlab4j.models.utils.JacksonJson;
import org.gitlab4j.models.utils.JacksonJsonEnumHelper;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

public class LineRange implements Serializable {
private static final long serialVersionUID = 1L;

public static class Position implements Serializable {
private static final long serialVersionUID = 1L;

public static enum PositionType {
OLD,
NEW;
private static JacksonJsonEnumHelper<PositionType> enumHelper =
new JacksonJsonEnumHelper<>(PositionType.class, false, false);

@JsonCreator
public static PositionType forValue(String value) {
return enumHelper.forValue(value);
}

@JsonValue
public String toValue() {
return (enumHelper.toString(this));
}

@Override
public String toString() {
return (enumHelper.toString(this));
}
}

private String lineCode;
private PositionType type;
private Integer oldLine;
private Integer newLine;

public String getLineCode() {
return lineCode;
}

public void setLineCode(String lineCode) {
this.lineCode = lineCode;
}

public Position withLineCode(String lineCode) {
this.lineCode = lineCode;
return this;
}

public PositionType getType() {
return type;
}

public void setType(PositionType type) {
this.type = type;
}

public Position withType(PositionType type) {
this.type = type;
return this;
}

public Integer getOldLine() {
return oldLine;
}

public void setOldLine(Integer oldLine) {
this.oldLine = oldLine;
}

public Position withOldLine(Integer oldLine) {
this.oldLine = oldLine;
return this;
}

public Integer getNewLine() {
return newLine;
}

public void setNewLine(Integer newLine) {
this.newLine = newLine;
}

public Position withNewLine(Integer newLine) {
this.newLine = newLine;
return this;
}

@Override
public String toString() {
return (JacksonJson.toJsonString(this));
}
}

private Position start;
private Position end;

public Position getStart() {
return start;
}

public void setStart(Position start) {
this.start = start;
}

public LineRange withStart(Position start) {
this.start = start;
return this;
}

public Position getEnd() {
return end;
}

public void setEnd(Position end) {
this.end = end;
}

public LineRange withEnd(Position end) {
this.end = end;
return this;
}

@Override
public String toString() {
return (JacksonJson.toJsonString(this));
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is probably a test case in TestGitLabApiBeans testing that the java class Position can be serialized and serialized.

It would be good to extend this test (probably extend the JSON used by the test, to reflect this change)

Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public String toString() {
private Integer height;
private Double x;
private Double y;
private LineRange lineRange;

public String getBaseSha() {
return baseSha;
Expand Down Expand Up @@ -205,6 +206,19 @@ public Position withY(Double y) {
return (this);
}

public LineRange getLineRange() {
return lineRange;
}

public void setLineRange(LineRange lineRange) {
this.lineRange = lineRange;
}

public Position withLineRange(LineRange lineRange) {
this.lineRange = lineRange;
return (this);
}

@Override
public String toString() {
return (JacksonJson.toJsonString(this));
Expand Down
Loading