Skip to content

Commit

Permalink
Allow to use Integer for ids
Browse files Browse the repository at this point in the history
  • Loading branch information
jmini committed Feb 5, 2024
1 parent 7b07abd commit ca5b712
Showing 1 changed file with 15 additions and 0 deletions.
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

0 comments on commit ca5b712

Please sign in to comment.