|
9 | 9 | import org.elasticsearch.common.ParseField;
|
10 | 10 | import org.elasticsearch.common.io.stream.StreamInput;
|
11 | 11 | import org.elasticsearch.common.io.stream.StreamOutput;
|
12 |
| -import org.elasticsearch.common.xcontent.ConstructingObjectParser; |
13 | 12 | import org.elasticsearch.common.xcontent.ToXContentObject;
|
14 | 13 | import org.elasticsearch.common.xcontent.XContentBuilder;
|
15 |
| -import org.elasticsearch.common.xcontent.XContentParser; |
16 | 14 |
|
17 | 15 | import java.io.IOException;
|
18 | 16 | import java.util.Map;
|
19 | 17 | import java.util.Objects;
|
20 |
| -import java.util.stream.Collectors; |
21 |
| - |
22 |
| -import static org.elasticsearch.common.xcontent.ConstructingObjectParser.constructorArg; |
23 | 18 |
|
24 | 19 | public class IndexUpgradeInfoResponse extends ActionResponse implements ToXContentObject {
|
25 | 20 |
|
26 | 21 | private static final ParseField INDICES = new ParseField("indices");
|
27 | 22 | private static final ParseField ACTION_REQUIRED = new ParseField("action_required");
|
28 | 23 |
|
29 |
| - private static final ConstructingObjectParser<IndexUpgradeInfoResponse, String> PARSER = |
30 |
| - new ConstructingObjectParser<>("IndexUpgradeInfoResponse", |
31 |
| - true, |
32 |
| - (a, c) -> { |
33 |
| - @SuppressWarnings("unchecked") |
34 |
| - Map<String, Object> map = (Map<String, Object>)a[0]; |
35 |
| - Map<String, UpgradeActionRequired> actionsRequired = map.entrySet().stream() |
36 |
| - .filter(e -> { |
37 |
| - if (e.getValue() instanceof Map == false) { |
38 |
| - return false; |
39 |
| - } |
40 |
| - @SuppressWarnings("unchecked") |
41 |
| - Map<String, Object> value =(Map<String, Object>)e.getValue(); |
42 |
| - return value.containsKey(ACTION_REQUIRED.getPreferredName()); |
43 |
| - }) |
44 |
| - .collect(Collectors.toMap( |
45 |
| - Map.Entry::getKey, |
46 |
| - e -> { |
47 |
| - @SuppressWarnings("unchecked") |
48 |
| - Map<String, Object> value = (Map<String, Object>) e.getValue(); |
49 |
| - return UpgradeActionRequired.fromString((String)value.get(ACTION_REQUIRED.getPreferredName())); |
50 |
| - } |
51 |
| - )); |
52 |
| - return new IndexUpgradeInfoResponse(actionsRequired); |
53 |
| - }); |
54 |
| - |
55 |
| - static { |
56 |
| - PARSER.declareObject(constructorArg(), (p, c) -> p.map(), INDICES); |
57 |
| - } |
58 |
| - |
59 |
| - |
60 | 24 | private Map<String, UpgradeActionRequired> actions;
|
61 | 25 |
|
62 | 26 | public IndexUpgradeInfoResponse() {
|
@@ -113,8 +77,4 @@ public boolean equals(Object o) {
|
113 | 77 | public int hashCode() {
|
114 | 78 | return Objects.hash(actions);
|
115 | 79 | }
|
116 |
| - |
117 |
| - public static IndexUpgradeInfoResponse fromXContent(XContentParser parser) { |
118 |
| - return PARSER.apply(parser, null); |
119 |
| - } |
120 | 80 | }
|
0 commit comments