From 0b449bd40a287d2d03ae6ec96c0b27f652b3bc7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Bresson?= Date: Mon, 2 Dec 2024 14:27:45 +0100 Subject: [PATCH] Add "values()" on search scopes (#1203) --- .../java/org/gitlab4j/models/Constants.java | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/gitlab4j-models/src/main/java/org/gitlab4j/models/Constants.java b/gitlab4j-models/src/main/java/org/gitlab4j/models/Constants.java index 840033bc..476ceb14 100644 --- a/gitlab4j-models/src/main/java/org/gitlab4j/models/Constants.java +++ b/gitlab4j-models/src/main/java/org/gitlab4j/models/Constants.java @@ -3,6 +3,7 @@ import java.util.Arrays; import java.util.HashMap; import java.util.Map; +import java.util.Set; import java.util.function.Function; import java.util.stream.Collectors; @@ -898,7 +899,7 @@ public Class getResultType() { public static final SearchScope COMMITS = new SearchScope<>("commits", Commit.class); public static final SearchScope WIKI_BLOBS = new SearchScope<>("wiki_blobs", SearchBlob.class); - private static final Map jsonLookup = Arrays.stream(new SearchScope[] { + private static final Map> jsonLookup = Arrays.stream(new SearchScope[] { PROJECTS, ISSUES, MERGE_REQUESTS, @@ -913,10 +914,15 @@ public Class getResultType() { .collect(Collectors.toMap(searchScope -> searchScope.jsonName, Function.identity())); @JsonCreator + @SuppressWarnings("unchecked") public static SearchScope forValue(String value) { return (SearchScope) jsonLookup.get(value); } + public Set values() { + return jsonLookup.keySet(); + } + @JsonValue public String toValue() { return jsonName; @@ -958,16 +964,21 @@ public Class getResultType() { public static final GroupSearchScope NOTES = new GroupSearchScope<>("notes", Note.class); public static final GroupSearchScope USERS = new GroupSearchScope<>("users", User.class); - private static final Map jsonLookup = Arrays.stream(new GroupSearchScope[] { + private static final Map> jsonLookup = Arrays.stream(new GroupSearchScope[] { PROJECTS, ISSUES, MERGE_REQUESTS, MILESTONES, WIKI_BLOBS, COMMITS, BLOBS, NOTES, USERS, }) .collect(Collectors.toMap(searchScope -> searchScope.jsonName, Function.identity())); @JsonCreator + @SuppressWarnings("unchecked") public static GroupSearchScope forValue(String value) { return (GroupSearchScope) jsonLookup.get(value); } + public Set values() { + return jsonLookup.keySet(); + } + @JsonValue public String toValue() { return jsonName; @@ -1008,16 +1019,21 @@ public Class getResultType() { new ProjectSearchScope<>("wiki_blobs", SearchBlob.class); public static final ProjectSearchScope USERS = new ProjectSearchScope<>("users", User.class); - private static final Map jsonLookup = Arrays.stream(new ProjectSearchScope[] { + private static final Map> jsonLookup = Arrays.stream(new ProjectSearchScope[] { BLOBS, COMMITS, ISSUES, MERGE_REQUESTS, MILESTONES, NOTES, WIKI_BLOBS, USERS, }) .collect(Collectors.toMap(searchScope -> searchScope.jsonName, Function.identity())); @JsonCreator + @SuppressWarnings("unchecked") public static ProjectSearchScope forValue(String value) { return (ProjectSearchScope) jsonLookup.get(value); } + public Set values() { + return jsonLookup.keySet(); + } + @JsonValue public String toValue() { return jsonName;