public interface StructuredOutput
Modifier and Type | Method and Description |
---|---|
<E> StructuredOutput |
array(String name,
Collection<E> array,
BiConsumer<StructuredOutput,E> arrayConsumer)
Outputs the given collection as array while using the given arrayConsumer to generate the array
contents.
|
StructuredOutput |
array(String name,
String elementName,
Collection<?> array)
Outputs the given collection as array.
|
StructuredOutput |
beginArray(String name)
Starts an array with is added to the current object as "name".
|
StructuredOutput |
beginObject(String name)
Starts a new object with the given name.
|
StructuredOutput |
beginObject(String name,
Attribute... attributes)
Starts a new object with the given name and attributes
|
StructuredOutput |
beginResult()
Starts the result with a default root element ("result").
|
StructuredOutput |
beginResult(String name)
Starts the result by specifying the name of the root element.
|
StructuredOutput |
endArray()
Ends the currently open array.
|
StructuredOutput |
endObject()
Ends the currently open object.
|
void |
endResult()
Finishes (closes) the result
|
StructuredOutput |
nullsafeProperty(String name,
Object data)
Adds a property to the current object.
|
StructuredOutput |
property(String name,
Object data)
Adds a property to the current object.
|
StructuredOutput beginResult()
StructuredOutput beginResult(@Nonnull String name)
name
- the name of the root elementvoid endResult()
StructuredOutput beginObject(@Nonnull String name)
name
- the name of the element to startStructuredOutput beginObject(@Nonnull String name, Attribute... attributes)
name
- the name of the object to createattributes
- the attributes to add to the objectStructuredOutput endObject()
StructuredOutput property(@Nonnull String name, @Nullable Object data)
name
- the name of the propertydata
- the value of the propertyStructuredOutput nullsafeProperty(@Nonnull String name, @Nullable Object data)
This will create a property with the specified data as value or empty string if the value is null.
name
- the name of the propertydata
- the value of the propertyStructuredOutput beginArray(@Nonnull String name)
name
- the name of the arrayStructuredOutput endArray()
StructuredOutput array(@Nonnull String name, @Nonnull String elementName, @Nonnull Collection<?> array)
This will create a property with the given name and the given array as value
name
- the name of the propertyelementName
- the name used to generate inner elements (if required, e.g. XML)array
- the array to output<E> StructuredOutput array(@Nonnull String name, @Nonnull Collection<E> array, BiConsumer<StructuredOutput,E> arrayConsumer)
E
- the type of elements in arrayname
- the name of the array property to createarray
- the collection to generate inner elementsarrayConsumer
- the consumer which creates the array content per child element in arrayCopyright © 2018. All rights reserved.