Skip to content

Commit 364ca3c

Browse files
committed
API simplifications
Signed-off-by: Nils Bandener <nils.bandener@eliatra.com>
1 parent e9b89a4 commit 364ca3c

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

server/src/main/java/org/opensearch/cluster/metadata/ResolvedIndices.java

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public int hashCode() {
159159
public static class Local extends OptionallyResolvedIndices.Local {
160160
protected final Set<String> names;
161161
protected final OriginalIndices originalIndices;
162-
protected final Map<ActionType<?>, Local> subActions;
162+
protected final Map<String, Local> subActions;
163163
private Set<String> namesOfIndices;
164164

165165
public static Local of(Collection<String> names) {
@@ -177,7 +177,7 @@ public static Local of(String... names) {
177177
* For this reason, this constructor is private. This contract is guaranteed by the static
178178
* constructor methods in this file.
179179
*/
180-
private Local(Set<String> names, OriginalIndices originalIndices, Map<ActionType<?>, Local> subActions) {
180+
private Local(Set<String> names, OriginalIndices originalIndices, Map<String, Local> subActions) {
181181
this.names = names;
182182
this.originalIndices = originalIndices;
183183
this.subActions = subActions;
@@ -266,7 +266,7 @@ public OriginalIndices originalIndices() {
266266
* For example, the swiss-army-knife IndicesAliases action can delete indices. The subActions() property
267267
* can be used to specify indices with such special roles.
268268
*/
269-
public Map<ActionType<?>, Local> subActions() {
269+
public Map<String, Local> subActions() {
270270
return this.subActions;
271271
}
272272

@@ -310,12 +310,16 @@ public ResolvedIndices.Local withOriginalIndices(OriginalIndices originalIndices
310310
return new Local(this.names, originalIndices, this.subActions);
311311
}
312312

313-
public ResolvedIndices.Local withSubActions(ActionType<?> actionType, ResolvedIndices.Local local) {
314-
Map<ActionType<?>, Local> subActions = new HashMap<>(this.subActions);
315-
subActions.put(actionType, local);
313+
public ResolvedIndices.Local withSubActions(String key, ResolvedIndices.Local local) {
314+
Map<String, Local> subActions = new HashMap<>(this.subActions);
315+
subActions.put(key, local);
316316
return new Local(this.names, this.originalIndices, Collections.unmodifiableMap(subActions));
317317
}
318318

319+
public ResolvedIndices.Local withSubActions(ActionType<?> actionType, ResolvedIndices.Local local) {
320+
return this.withSubActions(actionType.name(), local);
321+
}
322+
319323
@Override
320324
public String toString() {
321325
if (this.subActions.isEmpty()) {
@@ -384,7 +388,7 @@ private Concrete(
384388
Set<Index> concreteIndices,
385389
Set<String> names,
386390
OriginalIndices originalIndices,
387-
Map<ActionType<?>, Local> subActions,
391+
Map<String, Local> subActions,
388392
List<RuntimeException> resolutionErrors
389393
) {
390394
super(names, originalIndices, subActions);
@@ -420,12 +424,14 @@ public String[] namesOfConcreteIndicesAsArray() {
420424
return this.concreteIndices().stream().map(Index::getName).toArray(String[]::new);
421425
}
422426

427+
@Override
423428
public ResolvedIndices.Local.Concrete withOriginalIndices(OriginalIndices originalIndices) {
424429
return new Concrete(this.concreteIndices, this.names, originalIndices, this.subActions, resolutionErrors);
425430
}
426431

427-
public ResolvedIndices.Local withSubActions(ActionType<?> actionType, ResolvedIndices.Local local) {
428-
Map<ActionType<?>, Local> subActions = new HashMap<>(this.subActions);
432+
@Override
433+
public ResolvedIndices.Local withSubActions(String actionType, ResolvedIndices.Local local) {
434+
Map<String, Local> subActions = new HashMap<>(this.subActions);
429435
subActions.put(actionType, local);
430436
return new Concrete(this.concreteIndices, this.names, this.originalIndices, subActions, resolutionErrors);
431437
}

0 commit comments

Comments
 (0)