-
public final class KotlinExtensionsKt
-
-
Method Summary
Modifier and Type Method Description final String
stringify(ToXContent $self, Boolean pretty)
Helper to stringify to json. final Unit
stringify(ToXContent $self, OutputStream out, Boolean pretty)
Helper to write json to an output stream. final String
stringify(XContentBuilder $self)
Helper to write XContentBuilder to string. final Unit
writeAny(XContentBuilder $self, Object obj)
Write any of the supported types as a value. final Unit
obj(XContentBuilder $self, Function1<XContentBuilder, Unit> block)
Add an object using a block. final Unit
objField(XContentBuilder $self, String name, Function1<XContentBuilder, Unit> block)
Add a field with name with an object as the value; use the block to customise the object. final Unit
arrField(XContentBuilder $self, String name, Function1<XContentBuilder, Unit> block)
Add a field with name with an array as the value; use the block to customise the array. final XContentBuilder
xContentBuilder(Object obj)
Turn common objects like maps, lists, values, etc. -
-
Method Detail
-
stringify
final String stringify(ToXContent $self, Boolean pretty)
Helper to stringify to json.
- Parameters:
pretty
- pretty print, defaults to false
-
stringify
final Unit stringify(ToXContent $self, OutputStream out, Boolean pretty)
Helper to write json to an output stream. Set pretty to true to pretty print the json.
-
stringify
final String stringify(XContentBuilder $self)
Helper to write XContentBuilder to string. Note. if you want pretty printing, you need to enable that on the builder before you start building. Also, this only works if the underlying outputstream is a ByteArrayOutputStream.
-
writeAny
final Unit writeAny(XContentBuilder $self, Object obj)
Write any of the supported types as a value. Supports primitive and null values, Map, List, Sequence, Array, etc. You can even have another XContentBuilder nested.
-
obj
final Unit obj(XContentBuilder $self, Function1<XContentBuilder, Unit> block)
Add an object using a block.
-
objField
final Unit objField(XContentBuilder $self, String name, Function1<XContentBuilder, Unit> block)
Add a field with name with an object as the value; use the block to customise the object.
-
arrField
final Unit arrField(XContentBuilder $self, String name, Function1<XContentBuilder, Unit> block)
Add a field with name with an array as the value; use the block to customise the array.
-
xContentBuilder
final XContentBuilder xContentBuilder(Object obj)
Turn common objects like maps, lists, values, etc. into an XContentBuilder. Supports whatever is supported in writeAny.
-
-
-
-