Skip to content

Commit ca5b712

Browse files
committed
Allow to use Integer for ids
Fixes #1078
1 parent 7b07abd commit ca5b712

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/main/java/org/gitlab4j/api/AbstractApi.java

+15
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ public Object getProjectIdOrPath(Object obj) throws GitLabApiException {
4343
throw (new RuntimeException("Cannot determine ID or path from null object"));
4444
} else if (obj instanceof Long) {
4545
return (obj);
46+
} else if (obj instanceof Integer) {
47+
//Compatibility with older version of gitlab4j-api:
48+
return Long.valueOf(((Integer) obj).longValue());
4649
} else if (obj instanceof String) {
4750
return (urlEncode(((String) obj).trim()));
4851
} else if (obj instanceof Project) {
@@ -78,6 +81,9 @@ public Object getGroupIdOrPath(Object obj) throws GitLabApiException {
7881
throw (new RuntimeException("Cannot determine ID or path from null object"));
7982
} else if (obj instanceof Long) {
8083
return (obj);
84+
} else if (obj instanceof Integer) {
85+
//Compatibility with older version of gitlab4j-api:
86+
return Long.valueOf(((Integer) obj).longValue());
8187
} else if (obj instanceof String) {
8288
return (urlEncode(((String) obj).trim()));
8389
} else if (obj instanceof Group) {
@@ -113,6 +119,9 @@ public Object getUserIdOrUsername(Object obj) throws GitLabApiException {
113119
throw (new RuntimeException("Cannot determine ID or username from null object"));
114120
} else if (obj instanceof Long) {
115121
return (obj);
122+
} else if (obj instanceof Integer) {
123+
//Compatibility with older version of gitlab4j-api:
124+
return Long.valueOf(((Integer) obj).longValue());
116125
} else if (obj instanceof String) {
117126
return (urlEncode(((String) obj).trim()));
118127
} else if (obj instanceof User) {
@@ -148,6 +157,9 @@ public Object getLabelIdOrName(Object obj) throws GitLabApiException {
148157
throw (new RuntimeException("Cannot determine ID or name from null object"));
149158
} else if (obj instanceof Long) {
150159
return (obj);
160+
} else if (obj instanceof Integer) {
161+
//Compatibility with older version of gitlab4j-api:
162+
return Long.valueOf(((Integer) obj).longValue());
151163
} else if (obj instanceof String) {
152164
return (urlEncode(((String) obj).trim()));
153165
} else if (obj instanceof Label) {
@@ -176,6 +188,9 @@ public Object getNamespaceIdOrPath(Object obj) throws GitLabApiException {
176188
throw (new RuntimeException("Cannot determine ID or path from null object"));
177189
} else if (obj instanceof Long) {
178190
return (obj);
191+
} else if (obj instanceof Integer) {
192+
//Compatibility with older version of gitlab4j-api:
193+
return Long.valueOf(((Integer) obj).longValue());
179194
} else if (obj instanceof String) {
180195
return (urlEncode(((String) obj).trim()));
181196
} else if (obj instanceof Namespace) {

0 commit comments

Comments
 (0)