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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • loadWorkspaceFromJson

      public static com.structurizr.Workspace loadWorkspaceFromJson​(java.io.File file) throws java.lang.Exception
      Loads 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.Exception
      Saves a workspace to a JSON definition as a file.
      Parameters:
      workspace - a Workspace object
      file - 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.Exception
      Serializes the specified workspace to a JSON string.
      Parameters:
      workspace - a Workspace instance
      indentOutput - 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.Exception
      Converts 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