2525import org .elasticsearch .common .io .stream .StreamOutput ;
2626import org .elasticsearch .common .xcontent .AbstractObjectParser ;
2727import org .elasticsearch .common .xcontent .ObjectParser ;
28+ import org .elasticsearch .common .xcontent .XContentBuilder ;
2829import org .elasticsearch .common .xcontent .XContentParser ;
30+ import org .elasticsearch .common .xcontent .ToXContent .Params ;
2931import org .elasticsearch .script .Script ;
3032import org .elasticsearch .search .aggregations .support .ValueType ;
3133
3234import java .io .IOException ;
3335
3436import static org .elasticsearch .common .xcontent .XContentParserUtils .ensureExpectedToken ;
3537
36- class CompositeValuesSourceParserHelper {
38+ public class CompositeValuesSourceParserHelper {
3739 static <VB extends CompositeValuesSourceBuilder <VB >, T > void declareValuesSourceFields (AbstractObjectParser <VB , T > objectParser ,
3840 ValueType targetValueType ) {
3941 objectParser .declareField (VB ::field , XContentParser ::text ,
@@ -57,7 +59,7 @@ static <VB extends CompositeValuesSourceBuilder<VB>, T> void declareValuesSource
5759 objectParser .declareField (VB ::order , XContentParser ::text , new ParseField ("order" ), ObjectParser .ValueType .STRING );
5860 }
5961
60- static void writeTo (CompositeValuesSourceBuilder <?> builder , StreamOutput out ) throws IOException {
62+ public static void writeTo (CompositeValuesSourceBuilder <?> builder , StreamOutput out ) throws IOException {
6163 final byte code ;
6264 if (builder .getClass () == TermsValuesSourceBuilder .class ) {
6365 code = 0 ;
@@ -72,7 +74,7 @@ static void writeTo(CompositeValuesSourceBuilder<?> builder, StreamOutput out) t
7274 builder .writeTo (out );
7375 }
7476
75- static CompositeValuesSourceBuilder <?> readFrom (StreamInput in ) throws IOException {
77+ public static CompositeValuesSourceBuilder <?> readFrom (StreamInput in ) throws IOException {
7678 int code = in .readByte ();
7779 switch (code ) {
7880 case 0 :
@@ -86,7 +88,7 @@ static CompositeValuesSourceBuilder<?> readFrom(StreamInput in) throws IOExcepti
8688 }
8789 }
8890
89- static CompositeValuesSourceBuilder <?> fromXContent (XContentParser parser ) throws IOException {
91+ public static CompositeValuesSourceBuilder <?> fromXContent (XContentParser parser ) throws IOException {
9092 XContentParser .Token token = parser .currentToken ();
9193 ensureExpectedToken (XContentParser .Token .START_OBJECT , token , parser ::getTokenLocation );
9294 token = parser .nextToken ();
@@ -117,4 +119,14 @@ static CompositeValuesSourceBuilder<?> fromXContent(XContentParser parser) throw
117119 parser .nextToken ();
118120 return builder ;
119121 }
122+
123+ public static XContentBuilder toXContent (CompositeValuesSourceBuilder <?> source , XContentBuilder builder , Params params )
124+ throws IOException {
125+ builder .startObject ();
126+ builder .startObject (source .name ());
127+ source .toXContent (builder , params );
128+ builder .endObject ();
129+ builder .endObject ();
130+ return builder ;
131+ }
120132}
0 commit comments