Package step.functions.io
Class OutputBuilder
- java.lang.Object
-
- step.functions.io.OutputBuilder
-
public class OutputBuilder extends Object
A builder for Output instances.
-
-
Constructor Summary
Constructors Constructor Description OutputBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description OutputBuilderadd(String name, boolean value)Adds an output attribute If the object contains a mapping for the specified name, this method replaces the old value with the specified value.OutputBuilderadd(String name, double value)Adds an output attribute If the object contains a mapping for the specified name, this method replaces the old value with the specified value.OutputBuilderadd(String name, int value)Adds an output attribute If the object contains a mapping for the specified name, this method replaces the old value with the specified value.OutputBuilderadd(String name, long value)Adds an output attribute If the object contains a mapping for the specified name, this method replaces the old value with the specified value.OutputBuilderadd(String name, String value)Adds an output attribute If the object contains a mapping for the specified name, this method replaces the old value with the specified value.voidaddAttachment(Attachment attachment)Adds an attachment to the outputvoidaddAttachments(List<Attachment> attachments)Adds attachments to the outputvoidaddMeasure(String measureName, long durationMillis)Adds a performance measurementvoidaddMeasure(String measureName, long aDurationMillis, Map<String,Object> data)Adds a performance measurement with custom dataOutputBuilderappendError(String technicalError)Appends a technical error message.Output<javax.json.JsonObject>build()Builds the output instancejavax.json.JsonObjectBuildergetPayloadBuilder()StringgetPayloadJson()OutputBuildersetBusinessError(String businessError)Reports a business error.OutputBuildersetError(String technicalError)Reports a technical error.OutputBuildersetError(String errorMessage, Throwable e)Reports a technical error and appends the exception causing this error as attachmentOutputBuildersetError(Error error)voidsetLastMeasureAdditionalData(Map<String,Object> data)voidsetPayloadBuilder(javax.json.JsonObjectBuilder payloadBuilder)voidsetPayloadJson(String payloadJson)voidstartMeasure(String id)Starts a performance measurement.voidstartMeasure(String id, long begin)Starts a performance measurementvoidstopMeasure()Stops the current performance measurement and adds it to the outputvoidstopMeasure(Map<String,Object> data)Stops the current performance measurement and adds it to the output.voidstopMeasureForAdditionalData()
-
-
-
Method Detail
-
getPayloadBuilder
public javax.json.JsonObjectBuilder getPayloadBuilder()
-
setPayloadBuilder
public void setPayloadBuilder(javax.json.JsonObjectBuilder payloadBuilder)
-
add
public OutputBuilder add(String name, boolean value)
Adds an output attribute If the object contains a mapping for the specified name, this method replaces the old value with the specified value.- Parameters:
name- the name of the output attributevalue- the value of the output attribute- Returns:
- this instance
-
add
public OutputBuilder add(String name, double value)
Adds an output attribute If the object contains a mapping for the specified name, this method replaces the old value with the specified value.- Parameters:
name- the name of the output attributevalue- the value of the output attribute- Returns:
- this instance
-
add
public OutputBuilder add(String name, int value)
Adds an output attribute If the object contains a mapping for the specified name, this method replaces the old value with the specified value.- Parameters:
name- the name of the output attributevalue- the value of the output attribute- Returns:
- this instance
-
add
public OutputBuilder add(String name, long value)
Adds an output attribute If the object contains a mapping for the specified name, this method replaces the old value with the specified value.- Parameters:
name- the name of the output attributevalue- the value of the output attribute- Returns:
- this instance
-
add
public OutputBuilder add(String name, String value)
Adds an output attribute If the object contains a mapping for the specified name, this method replaces the old value with the specified value.- Parameters:
name- the name of the output attributevalue- the value of the output attribute- Returns:
- this instance
-
setError
public OutputBuilder setError(String technicalError)
Reports a technical error. This will be reported as ERROR in STEP- Parameters:
technicalError- the error message of the technical error- Returns:
- this instance
-
appendError
public OutputBuilder appendError(String technicalError)
Appends a technical error message. Calling this method for the first time will have the same effect as calling setError- Parameters:
technicalError- the error message of the technical error- Returns:
- this instance
-
setError
public OutputBuilder setError(String errorMessage, Throwable e)
Reports a technical error and appends the exception causing this error as attachment- Parameters:
errorMessage- the error message of the technical errore- the exception that caused the technical error- Returns:
- this instance
-
setBusinessError
public OutputBuilder setBusinessError(String businessError)
Reports a business error. This will be reported as FAILED in STEP- Parameters:
businessError- the error message of the business error- Returns:
- this instance
-
setError
public OutputBuilder setError(Error error)
-
getPayloadJson
public String getPayloadJson()
- Returns:
- the payload of this output. This has no eff
-
setPayloadJson
public void setPayloadJson(String payloadJson)
- Parameters:
payloadJson- the payload of this output.
-
addAttachments
public void addAttachments(List<Attachment> attachments)
Adds attachments to the output- Parameters:
attachments- the list of attachments to be added to the output
-
addAttachment
public void addAttachment(Attachment attachment)
Adds an attachment to the output- Parameters:
attachment- the attachment to be added to the output
-
startMeasure
public void startMeasure(String id)
Starts a performance measurement. The current time will be used as starttime- Parameters:
id- a unique identifier of the measurement
-
startMeasure
public void startMeasure(String id, long begin)
Starts a performance measurement- Parameters:
id- a unique identifier of the measurementbegin- the start time of the measurement
-
addMeasure
public void addMeasure(String measureName, long durationMillis)
Adds a performance measurement- Parameters:
measureName- a unique identifier of the measurementdurationMillis- the duration of the measurement in ms
-
addMeasure
public void addMeasure(String measureName, long aDurationMillis, Map<String,Object> data)
Adds a performance measurement with custom data- Parameters:
measureName- a unique identifier of the measurementaDurationMillis- the duration of the measurement in msdata- the custom data of the measurement
-
stopMeasure
public void stopMeasure()
Stops the current performance measurement and adds it to the output
-
stopMeasure
public void stopMeasure(Map<String,Object> data)
Stops the current performance measurement and adds it to the output.- Parameters:
data- custom data to be added to the measurement
-
stopMeasureForAdditionalData
public void stopMeasureForAdditionalData()
-
build
public Output<javax.json.JsonObject> build()
Builds the output instance- Returns:
- the output message
-
-