Package com.structurizr.util
Class WorkspaceUtils
java.lang.Object
com.structurizr.util.WorkspaceUtils
public final class WorkspaceUtils
extends java.lang.Object
Some utility methods related to workspaces.
-
Constructor Summary
Constructors Constructor Description WorkspaceUtils()
-
Method Summary
Modifier and Type Method Description static com.structurizr.Workspace
fromJson(java.lang.String json)
Converts the specified JSON string to a Workspace instance.static com.structurizr.Workspace
loadWorkspaceFromJson(java.io.File file)
Loads a workspace from a JSON definition saved as a file.static void
printWorkspaceAsJson(com.structurizr.Workspace workspace)
Prints a workspace as JSON to stdout - useful for debugging purposes.static void
saveWorkspaceToJson(com.structurizr.Workspace workspace, java.io.File file)
Saves a workspace to a JSON definition as a file.static java.lang.String
toJson(com.structurizr.Workspace workspace, boolean indentOutput)
Serializes the specified workspace to a JSON string.
-
Constructor Details
-
WorkspaceUtils
public WorkspaceUtils()
-
-
Method Details
-
loadWorkspaceFromJson
public static com.structurizr.Workspace loadWorkspaceFromJson(java.io.File file) throws java.lang.ExceptionLoads a workspace from a JSON definition saved as a file.- Parameters:
file
- a File representing the JSON definition- Returns:
- a Workspace object
- Throws:
java.lang.Exception
- if something goes wrong
-
saveWorkspaceToJson
public static void saveWorkspaceToJson(com.structurizr.Workspace workspace, java.io.File file) throws java.lang.ExceptionSaves a workspace to a JSON definition as a file.- Parameters:
workspace
- a Workspace objectfile
- a File representing the JSON definition- Throws:
java.lang.Exception
- if something goes wrong
-
printWorkspaceAsJson
public static void printWorkspaceAsJson(com.structurizr.Workspace workspace)Prints a workspace as JSON to stdout - useful for debugging purposes.- Parameters:
workspace
- the workspace to print
-
toJson
public static java.lang.String toJson(com.structurizr.Workspace workspace, boolean indentOutput) throws java.lang.ExceptionSerializes the specified workspace to a JSON string.- Parameters:
workspace
- a Workspace instanceindentOutput
- whether to indent the output (prettify)- Returns:
- a JSON string
- Throws:
java.lang.Exception
- if something goes wrong
-
fromJson
public static com.structurizr.Workspace fromJson(java.lang.String json) throws java.lang.ExceptionConverts the specified JSON string to a Workspace instance.- Parameters:
json
- the JSON definition of the workspace- Returns:
- a Workspace instance
- Throws:
java.lang.Exception
- if the JSON can not be deserialized
-