Package io.serverlessworkflow.api
Class WorkflowWriter
java.lang.Object
io.serverlessworkflow.api.WorkflowWriter
Utility class for writing Serverless Workflow definitions to various outputs and formats.
This class provides static methods to serialize Workflow objects to files, streams,
writers, byte arrays, or strings in either JSON or YAML format. The format is determined by the
WorkflowFormat parameter or inferred from file extensions.
-
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]workflowAsBytes(io.serverlessworkflow.api.types.Workflow workflow, WorkflowFormat format) Serializes aWorkflowto a byte array in the specified format.static StringworkflowAsString(io.serverlessworkflow.api.types.Workflow workflow, WorkflowFormat format) Serializes aWorkflowto a string in the specified format.static voidwriteWorkflow(OutputStream output, io.serverlessworkflow.api.types.Workflow workflow, WorkflowFormat format) Writes aWorkflowto the givenOutputStreamin the specified format.static voidwriteWorkflow(Writer output, io.serverlessworkflow.api.types.Workflow workflow, WorkflowFormat format) Writes aWorkflowto the givenWriterin the specified format.static voidwriteWorkflow(Path output, io.serverlessworkflow.api.types.Workflow workflow) Writes aWorkflowto the specified file path, inferring the format from the file extension.static voidwriteWorkflow(Path output, io.serverlessworkflow.api.types.Workflow workflow, WorkflowFormat format) Writes aWorkflowto the specified file path in the given format.
-
Method Details
-
writeWorkflow
public static void writeWorkflow(OutputStream output, io.serverlessworkflow.api.types.Workflow workflow, WorkflowFormat format) throws IOException Writes aWorkflowto the givenOutputStreamin the specified format.- Parameters:
output- the output stream to write the workflow toworkflow- the workflow object to serializeformat- the format to use (JSON or YAML)- Throws:
IOException- if an I/O error occurs during writing
-
writeWorkflow
public static void writeWorkflow(Writer output, io.serverlessworkflow.api.types.Workflow workflow, WorkflowFormat format) throws IOException Writes aWorkflowto the givenWriterin the specified format.- Parameters:
output- the writer to write the workflow toworkflow- the workflow object to serializeformat- the format to use (JSON or YAML)- Throws:
IOException- if an I/O error occurs during writing
-
writeWorkflow
public static void writeWorkflow(Path output, io.serverlessworkflow.api.types.Workflow workflow) throws IOException Writes aWorkflowto the specified file path, inferring the format from the file extension.- Parameters:
output- the file path to write the workflow toworkflow- the workflow object to serialize- Throws:
IOException- if an I/O error occurs during writing
-
writeWorkflow
public static void writeWorkflow(Path output, io.serverlessworkflow.api.types.Workflow workflow, WorkflowFormat format) throws IOException Writes aWorkflowto the specified file path in the given format.- Parameters:
output- the file path to write the workflow toworkflow- the workflow object to serializeformat- the format to use (JSON or YAML)- Throws:
IOException- if an I/O error occurs during writing
-
workflowAsString
public static String workflowAsString(io.serverlessworkflow.api.types.Workflow workflow, WorkflowFormat format) throws IOException Serializes aWorkflowto a string in the specified format.- Parameters:
workflow- the workflow object to serializeformat- the format to use (JSON or YAML)- Returns:
- the serialized workflow as a string
- Throws:
IOException- if an error occurs during serialization
-
workflowAsBytes
public static byte[] workflowAsBytes(io.serverlessworkflow.api.types.Workflow workflow, WorkflowFormat format) throws IOException Serializes aWorkflowto a byte array in the specified format.- Parameters:
workflow- the workflow object to serializeformat- the format to use (JSON or YAML)- Returns:
- the serialized workflow as a byte array
- Throws:
IOException- if an error occurs during serialization
-