Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Allow to use Integer for ids #1087

Merged
merged 1 commit into from
Feb 6, 2024
Merged
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
15 changes: 15 additions & 0 deletions src/main/java/org/gitlab4j/api/AbstractApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ public Object getProjectIdOrPath(Object obj) throws GitLabApiException {
throw (new RuntimeException("Cannot determine ID or path from null object"));
} else if (obj instanceof Long) {
return (obj);
} else if (obj instanceof Integer) {
//Compatibility with older version of gitlab4j-api:
return Long.valueOf(((Integer) obj).longValue());
} else if (obj instanceof String) {
return (urlEncode(((String) obj).trim()));
} else if (obj instanceof Project) {
Expand Down Expand Up @@ -78,6 +81,9 @@ public Object getGroupIdOrPath(Object obj) throws GitLabApiException {
throw (new RuntimeException("Cannot determine ID or path from null object"));
} else if (obj instanceof Long) {
return (obj);
} else if (obj instanceof Integer) {
//Compatibility with older version of gitlab4j-api:
return Long.valueOf(((Integer) obj).longValue());
} else if (obj instanceof String) {
return (urlEncode(((String) obj).trim()));
} else if (obj instanceof Group) {
Expand Down Expand Up @@ -113,6 +119,9 @@ public Object getUserIdOrUsername(Object obj) throws GitLabApiException {
throw (new RuntimeException("Cannot determine ID or username from null object"));
} else if (obj instanceof Long) {
return (obj);
} else if (obj instanceof Integer) {
//Compatibility with older version of gitlab4j-api:
return Long.valueOf(((Integer) obj).longValue());
} else if (obj instanceof String) {
return (urlEncode(((String) obj).trim()));
} else if (obj instanceof User) {
Expand Down Expand Up @@ -148,6 +157,9 @@ public Object getLabelIdOrName(Object obj) throws GitLabApiException {
throw (new RuntimeException("Cannot determine ID or name from null object"));
} else if (obj instanceof Long) {
return (obj);
} else if (obj instanceof Integer) {
//Compatibility with older version of gitlab4j-api:
return Long.valueOf(((Integer) obj).longValue());
} else if (obj instanceof String) {
return (urlEncode(((String) obj).trim()));
} else if (obj instanceof Label) {
Expand Down Expand Up @@ -176,6 +188,9 @@ public Object getNamespaceIdOrPath(Object obj) throws GitLabApiException {
throw (new RuntimeException("Cannot determine ID or path from null object"));
} else if (obj instanceof Long) {
return (obj);
} else if (obj instanceof Integer) {
//Compatibility with older version of gitlab4j-api:
return Long.valueOf(((Integer) obj).longValue());
} else if (obj instanceof String) {
return (urlEncode(((String) obj).trim()));
} else if (obj instanceof Namespace) {
Expand Down
Loading