@@ -121,26 +121,17 @@ public void writeTo(StreamOutput out) throws IOException {
121
121
@ Override
122
122
public XContentBuilder toXContent (XContentBuilder xContentBuilder , Params params ) throws IOException {
123
123
XContentBuilder builder = xContentBuilder .startObject ();
124
- if (type != null ) {
125
- builder .field (TYPE_FIELD , type );
124
+ if (configType != null || type != null ) {
125
+ builder .field (TYPE_FIELD , configType == null ? type : configType );
126
126
}
127
- if (configType != null ) {
128
- builder .field (CONFIG_TYPE_FIELD , configType );
129
- }
130
- if (configuration != null ) {
131
- builder .field (CONFIGURATION_FIELD , configuration );
132
- }
133
- if (mlConfiguration != null ) {
134
- builder .field (ML_CONFIGURATION_FIELD , mlConfiguration );
127
+ if (configuration != null || mlConfiguration != null ) {
128
+ builder .field (CONFIGURATION_FIELD , mlConfiguration == null ? configuration : mlConfiguration );
135
129
}
136
130
if (createTime != null ) {
137
131
builder .field (CREATE_TIME_FIELD , createTime .toEpochMilli ());
138
132
}
139
- if (lastUpdateTime != null ) {
140
- builder .field (LAST_UPDATE_TIME_FIELD , lastUpdateTime .toEpochMilli ());
141
- }
142
- if (lastUpdatedTime != null ) {
143
- builder .field (LAST_UPDATED_TIME_FIELD , lastUpdatedTime .toEpochMilli ());
133
+ if (lastUpdateTime != null || lastUpdatedTime != null ) {
134
+ builder .field (LAST_UPDATE_TIME_FIELD , lastUpdatedTime == null ? lastUpdateTime .toEpochMilli () : lastUpdatedTime .toEpochMilli ());
144
135
}
145
136
return builder .endObject ();
146
137
}
0 commit comments