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 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.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.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.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.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.void
addAttachment(Attachment attachment)
Adds an attachment to the outputvoid
addAttachments(List<Attachment> attachments)
Adds attachments to the outputvoid
addMeasure(String measureName, long durationMillis)
Adds a performance measurementvoid
addMeasure(String measureName, long aDurationMillis, Map<String,Object> data)
Adds a performance measurement with custom dataOutputBuilder
appendError(String technicalError)
Appends a technical error message.Output<javax.json.JsonObject>
build()
Builds the output instancejavax.json.JsonObjectBuilder
getPayloadBuilder()
String
getPayloadJson()
OutputBuilder
setBusinessError(String businessError)
Reports a business error.OutputBuilder
setError(String technicalError)
Reports a technical error.OutputBuilder
setError(String errorMessage, Throwable e)
Reports a technical error and appends the exception causing this error as attachmentOutputBuilder
setError(Error error)
void
setLastMeasureAdditionalData(Map<String,Object> data)
void
setPayloadBuilder(javax.json.JsonObjectBuilder payloadBuilder)
void
setPayloadJson(String payloadJson)
void
startMeasure(String id)
Starts a performance measurement.void
startMeasure(String id, long begin)
Starts a performance measurementvoid
stopMeasure()
Stops the current performance measurement and adds it to the outputvoid
stopMeasure(Map<String,Object> data)
Stops the current performance measurement and adds it to the output.void
stopMeasureForAdditionalData()
-
-
-
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
-
-