Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
135 changes: 135 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,135 @@
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));
}
}
28 changes: 28 additions & 0 deletions gitlab4j-models/src/main/java/org/gitlab4j/api/models/Note.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import org.gitlab4j.models.utils.JacksonJson;
import org.gitlab4j.models.utils.JacksonJsonEnumHelper;
Expand Down Expand Up @@ -96,7 +97,9 @@ public String toString() {
// Use String for noteableType until the constant is fixed in the GitLab API
private String noteableType;

private Long projectId;
private Long noteableIid;
private String commitId;
private Boolean system;
private String title;
private Date updatedAt;
Expand All @@ -109,6 +112,7 @@ public String toString() {
private Type type;

private Position position;
private List<Suggestion> suggestions;

public String getAttachment() {
return attachment;
Expand Down Expand Up @@ -190,6 +194,14 @@ public void setNoteableType(String noteableType) {
this.noteableType = noteableType;
}

public Long getProjectId() {
return projectId;
}

public void setProjectId(Long projectId) {
this.projectId = projectId;
}

public Long getNoteableIid() {
return noteableIid;
}
Expand All @@ -198,6 +210,14 @@ public void setNoteableIid(Long noteableIid) {
this.noteableIid = noteableIid;
}

public String getCommitId() {
return commitId;
}

public void setCommitId(String commitId) {
this.commitId = commitId;
}

public Boolean getSystem() {
return system;
}
Expand Down Expand Up @@ -286,6 +306,14 @@ public void setInternal(Boolean internal) {
this.internal = internal;
}

public List<Suggestion> getSuggestions() {
return suggestions;
}

public void setSuggestions(List<Suggestion> suggestions) {
this.suggestions = suggestions;
}

@Override
public String toString() {
return (JacksonJson.toJsonString(this));
Expand Down
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package org.gitlab4j.api.models;

import java.io.Serializable;

import org.gitlab4j.models.utils.JacksonJson;

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

private Long id;
private Long fromLine;
private Long toLine;
private Boolean appliable;
private Boolean applied;
private String fromContent;
private String toContent;

public Long getId() {
return id;
}

public void setId(Long id) {
this.id = id;
}

public Long getFromLine() {
return fromLine;
}

public void setFromLine(Long fromLine) {
this.fromLine = fromLine;
}

public Long getToLine() {
return toLine;
}

public void setToLine(Long toLine) {
this.toLine = toLine;
}

public Boolean getAppliable() {
return appliable;
}

public void setAppliable(Boolean appliable) {
this.appliable = appliable;
}

public Boolean getApplied() {
return applied;
}

public void setApplied(Boolean applied) {
this.applied = applied;
}

public String getFromContent() {
return fromContent;
}

public void setFromContent(String fromContent) {
this.fromContent = fromContent;
}

public String getToContent() {
return toContent;
}

public void setToContent(String toContent) {
this.toContent = toContent;
}

@Override
public String toString() {
return (JacksonJson.toJsonString(this));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,67 @@
"resolvable": true
}
]
},
{
"id": "87805b7c09016a7058e91bdbe7b29d1f284a39e6",
"individual_note": false,
"notes": [
{
"id": 1128,
"type": "DiffNote",
"body": "diff comment",
"author": {
"id": 1,
"name": "root",
"username": "root",
"state": "active",
"avatar_url": "https://www.gravatar.com/avatar/00afb8fb6ab07c3ee3e9c1f38777e2f4?s=80&d=identicon",
"web_url": "http://localhost:3000/root"
},
"created_at": "2018-03-04T09:17:22.520Z",
"updated_at": "2018-03-04T09:17:22.520Z",
"system": false,
"noteable_id": 3,
"noteable_type": "MergeRequest",
"project_id": 5,
"commit_id": "4803c71e6b1833ca72b8b26ef2ecd5adc8a38031",
"position": {
"base_sha": "b5d6e7b1613fca24d250fa8e5bc7bcc3dd6002ef",
"start_sha": "7c9c2ead8a320fb7ba0b4e234bd9529a2614e306",
"head_sha": "4803c71e6b1833ca72b8b26ef2ecd5adc8a38031",
"old_path": "package.json",
"new_path": "package.json",
"position_type": "text",
"old_line": 27,
"new_line": 27,
"line_range": {
"start": {
"line_code": "588440f66559714280628a4f9799f0c4eb880a4a_10_10",
"type": "new",
"new_line": 10
},
"end": {
"line_code": "588440f66559714280628a4f9799f0c4eb880a4a_11_11",
"type": "old",
"old_line": 11,
"new_line": 11
}
}
},
"resolved": false,
"resolvable": true,
"suggestions": [
{
"id": 1,
"from_line": 27,
"to_line": 27,
"appliable": true,
"applied": false,
"from_content": "x",
"to_content": "b"
}
]
}
]
}
]
Loading