27
27
import org .elasticsearch .common .xcontent .ToXContentObject ;
28
28
import org .elasticsearch .common .xcontent .XContentBuilder ;
29
29
import org .elasticsearch .common .xcontent .XContentParser ;
30
+ import org .elasticsearch .index .Index ;
30
31
31
32
import java .io .IOException ;
32
33
import java .util .List ;
@@ -36,9 +37,9 @@ public final class DataStream extends AbstractDiffable<DataStream> implements To
36
37
37
38
private final String name ;
38
39
private final String timeStampField ;
39
- private final List <String > indices ;
40
+ private final List <Index > indices ;
40
41
41
- public DataStream (String name , String timeStampField , List <String > indices ) {
42
+ public DataStream (String name , String timeStampField , List <Index > indices ) {
42
43
this .name = name ;
43
44
this .timeStampField = timeStampField ;
44
45
this .indices = indices ;
@@ -52,12 +53,12 @@ public String getTimeStampField() {
52
53
return timeStampField ;
53
54
}
54
55
55
- public List <String > getIndices () {
56
+ public List <Index > getIndices () {
56
57
return indices ;
57
58
}
58
59
59
60
public DataStream (StreamInput in ) throws IOException {
60
- this (in .readString (), in .readString (), in .readStringList ( ));
61
+ this (in .readString (), in .readString (), in .readList ( Index :: new ));
61
62
}
62
63
63
64
public static Diff <DataStream > readDiffFrom (StreamInput in ) throws IOException {
@@ -68,7 +69,7 @@ public static Diff<DataStream> readDiffFrom(StreamInput in) throws IOException {
68
69
public void writeTo (StreamOutput out ) throws IOException {
69
70
out .writeString (name );
70
71
out .writeString (timeStampField );
71
- out .writeStringCollection (indices );
72
+ out .writeList (indices );
72
73
}
73
74
74
75
public static final ParseField NAME_FIELD = new ParseField ("name" );
@@ -77,12 +78,12 @@ public void writeTo(StreamOutput out) throws IOException {
77
78
78
79
@ SuppressWarnings ("unchecked" )
79
80
private static final ConstructingObjectParser <DataStream , Void > PARSER = new ConstructingObjectParser <>("data_stream" ,
80
- args -> new DataStream ((String ) args [0 ], (String ) args [1 ], (List <String >) args [2 ]));
81
+ args -> new DataStream ((String ) args [0 ], (String ) args [1 ], (List <Index >) args [2 ]));
81
82
82
83
static {
83
84
PARSER .declareString (ConstructingObjectParser .constructorArg (), NAME_FIELD );
84
85
PARSER .declareString (ConstructingObjectParser .constructorArg (), TIMESTAMP_FIELD_FIELD );
85
- PARSER .declareStringArray (ConstructingObjectParser .constructorArg (), INDICES_FIELD );
86
+ PARSER .declareObjectArray (ConstructingObjectParser .constructorArg (), ( p , c ) -> Index . fromXContent ( p ), INDICES_FIELD );
86
87
}
87
88
88
89
public static DataStream fromXContent (XContentParser parser ) throws IOException {
0 commit comments