Class Model

java.lang.Object
com.structurizr.model.Model

public final class Model extends Object
Represents a software architecture model, into which all model elements are added.
  • Method Details

    • getEnterprise

      public Enterprise getEnterprise()
      Gets the enterprise associated with this model.
      Returns:
      an Enterprise instance, or null if one has not been set
    • setEnterprise

      public void setEnterprise(Enterprise enterprise)
      Sets the enterprise associated with this model.
      Parameters:
      enterprise - an Enterprise instance
    • addSoftwareSystem

      public SoftwareSystem addSoftwareSystem(@Nonnull String name)
      Creates a software system (with an unspecified location) and adds it to the model.
      Parameters:
      name - the name of the software system
      Returns:
      the SoftwareSystem instance created and added to the model (or null)
      Throws:
      IllegalArgumentException - if a software system with the same name already exists
    • addSoftwareSystem

      public SoftwareSystem addSoftwareSystem(@Nonnull String name, @Nullable String description)
      Creates a software system (with an unspecified location) and adds it to the model.
      Parameters:
      name - the name of the software system
      description - a short description of the software system
      Returns:
      the SoftwareSystem instance created and added to the model (or null)
      Throws:
      IllegalArgumentException - if a software system with the same name already exists
    • addSoftwareSystem

      @Nonnull public SoftwareSystem addSoftwareSystem(@Nullable Location location, @Nonnull String name, @Nullable String description)
      Creates a software system and adds it to the model.
      Parameters:
      location - the location of the software system (e.g. internal, external, etc)
      name - the name of the software system
      description - a short description of the software system
      Returns:
      the SoftwareSystem instance created and added to the model (or null)
      Throws:
      IllegalArgumentException - if a software system with the same name already exists
    • addPerson

      @Nonnull public Person addPerson(@Nonnull String name)
      Creates a person (with an unspecified location) and adds it to the model.
      Parameters:
      name - the name of the person (e.g. "Admin User" or "Bob the Business User")
      Returns:
      the Person instance created and added to the model (or null)
      Throws:
      IllegalArgumentException - if a person with the same name already exists
    • addPerson

      @Nonnull public Person addPerson(@Nonnull String name, @Nullable String description)
      Creates a person (with an unspecified location) and adds it to the model.
      Parameters:
      name - the name of the person (e.g. "Admin User" or "Bob the Business User")
      description - a short description of the person
      Returns:
      the Person instance created and added to the model (or null)
      Throws:
      IllegalArgumentException - if a person with the same name already exists
    • addPerson

      @Nonnull public Person addPerson(Location location, @Nonnull String name, @Nullable String description)
      Creates a person and adds it to the model.
      Parameters:
      location - the location of the person (e.g. internal, external, etc)
      name - the name of the person (e.g. "Admin User" or "Bob the Business User")
      description - a short description of the person
      Returns:
      the Person instance created and added to the model (or null)
      Throws:
      IllegalArgumentException - if a person with the same name already exists
    • addCustomElement

      @Nonnull public CustomElement addCustomElement(@Nonnull String name)
      Creates a custom element and adds it to the model.
      Parameters:
      name - the name of the custom element
      Returns:
      the CustomElement instance created and added to the model (or null)
      Throws:
      IllegalArgumentException - if a custom element/person/software system with the same name already exists
    • addCustomElement

      @Nonnull public CustomElement addCustomElement(@Nonnull String name, @Nullable String metadata, @Nullable String description)
      Creates a custom element and adds it to the model.
      Parameters:
      name - the name of the custom element
      description - a short description of the custom element
      metadata - the metadata of the custom element
      Returns:
      the CustomElement instance created and added to the model (or null)
      Throws:
      IllegalArgumentException - if a custom element/person/software system with the same name already exists
    • getElements

      @Nonnull public Set<Element> getElements()
      Gets the set of all elements in this model.
      Returns:
      a Set of Element instances
    • getElement

      @Nullable public Element getElement(@Nonnull String id)
      Gets the element with the specified ID.
      Parameters:
      id - the ModelItem.getId() of the element
      Returns:
      the element in this model with the specified ID (or null if it doesn't exist)
      See Also:
    • getRelationships

      @Nonnull public Set<Relationship> getRelationships()
      Gets the set of all relationships in this model.
      Returns:
      a Set of Relationship objects
    • getRelationship

      @Nullable public Relationship getRelationship(@Nonnull String id)
      Gets the relationship with the specified ID.
      Parameters:
      id - the ModelItem.getId() of the relationship
      Returns:
      the relationship in this model with the specified ID (or null if it doesn't exist).
      See Also:
    • getCustomElements

      @Nonnull public Set<CustomElement> getCustomElements()
      Gets the set of all custom elements in this model.
      Returns:
      a Set of CustomElement instances
    • getPeople

      @Nonnull public Set<Person> getPeople()
      Gets the set of all people in this model.
      Returns:
      a Set of Person instances
    • getSoftwareSystems

      @Nonnull public Set<SoftwareSystem> getSoftwareSystems()
      Gets the set of all software systems in this model.
      Returns:
      a Set of SoftwareSystem instances
    • getDeploymentNodes

      @Nonnull public Set<DeploymentNode> getDeploymentNodes()
      Gets the set of all top-level deployment nodes in this model.
      Returns:
      a Set of DeploymentNode instances
    • contains

      public boolean contains(Element element)
      Determines whether this model contains the specified element.
      Parameters:
      element - any element
      Returns:
      true, if the element is contained in this model
    • getSoftwareSystemWithName

      @Nullable public SoftwareSystem getSoftwareSystemWithName(@Nonnull String name)
      Gets the software system with the specified name.
      Parameters:
      name - the name of a SoftwareSystem
      Returns:
      the SoftwareSystem instance with the specified name (or null if it doesn't exist)
      Throws:
      IllegalArgumentException - if the name is null or empty
    • getSoftwareSystemWithId

      @Nullable public SoftwareSystem getSoftwareSystemWithId(@Nonnull String id)
      Gets the software system with the specified ID.
      Parameters:
      id - the ModelItem.getId() of the software system
      Returns:
      the SoftwareSystem instance with the specified ID (or null if it doesn't exist).
      Throws:
      IllegalArgumentException - if the id is null or empty
      See Also:
    • getPersonWithName

      @Nullable public Person getPersonWithName(@Nonnull String name)
      Gets the person with the specified name.
      Parameters:
      name - the name of the person
      Returns:
      the Person instance with the specified name (or null if it doesn't exist)
      Throws:
      IllegalArgumentException - if the name is null or empty
    • getCustomElementWithName

      @Nullable public CustomElement getCustomElementWithName(@Nonnull String name)
      Gets the custom element with the specified name.
      Parameters:
      name - the name of the custom element
      Returns:
      the CustomElement instance with the specified name (or null if it doesn't exist)
      Throws:
      IllegalArgumentException - if the name is null or empty
    • isEmpty

      public boolean isEmpty()
      Determines whether this model is empty.
      Returns:
      true if the model contains no people, software systems or deployment nodes; false otherwise
    • addDeploymentNode

      @Nonnull public DeploymentNode addDeploymentNode(@Nonnull String name)
      Adds a top-level deployment node to this model.
      Parameters:
      name - the name of the deployment node
      Returns:
      a DeploymentNode instance
      Throws:
      IllegalArgumentException - if the name is not specified, or a top-level deployment node with the same name already exists in the model
    • addDeploymentNode

      @Nonnull public DeploymentNode addDeploymentNode(@Nonnull String name, @Nullable String description, @Nullable String technology)
      Adds a top-level deployment node to this model.
      Parameters:
      name - the name of the deployment node
      description - the description of the deployment node
      technology - the technology associated with the deployment node
      Returns:
      a DeploymentNode instance
      Throws:
      IllegalArgumentException - if the name is not specified, or a top-level deployment node with the same name already exists in the model
    • addDeploymentNode

      @Nonnull public DeploymentNode addDeploymentNode(@Nullable String environment, @Nonnull String name, @Nullable String description, @Nullable String technology)
      Adds a top-level deployment node to this model.
      Parameters:
      environment - the name of the deployment environment
      name - the name of the deployment node
      description - the description of the deployment node
      technology - the technology associated with the deployment node
      Returns:
      a DeploymentNode instance
      Throws:
      IllegalArgumentException - if the name is not specified, or a top-level deployment node with the same name already exists in the model
    • addDeploymentNode

      @Nonnull public DeploymentNode addDeploymentNode(@Nonnull String name, @Nullable String description, @Nullable String technology, int instances)
      Adds a top-level deployment node to this model.
      Parameters:
      name - the name of the deployment node
      description - the description of the deployment node
      technology - the technology associated with the deployment node
      instances - the number of instances of the deployment node
      Returns:
      a DeploymentNode instance
      Throws:
      IllegalArgumentException - if the name is not specified, or a top-level deployment node with the same name already exists in the model
    • addDeploymentNode

      @Nonnull public DeploymentNode addDeploymentNode(@Nullable String environment, @Nonnull String name, @Nullable String description, @Nullable String technology, int instances)
      Adds a top-level deployment node to this model.
      Parameters:
      environment - the name of the deployment environment
      name - the name of the deployment node
      description - the description of the deployment node
      technology - the technology associated with the deployment node
      instances - the number of instances of the deployment node
      Returns:
      a DeploymentNode instance
      Throws:
      IllegalArgumentException - if the name is not specified, or a top-level deployment node with the same name already exists in the model
    • addDeploymentNode

      @Nonnull public DeploymentNode addDeploymentNode(@Nonnull String name, String description, String technology, int instances, Map<String,String> properties)
      Adds a top-level deployment node to this model.
      Parameters:
      name - the name of the deployment node
      description - the description of the deployment node
      technology - the technology associated with the deployment node
      instances - the number of instances of the deployment node
      properties - a map of name/value properties associated with the deployment node
      Returns:
      a DeploymentNode instance
      Throws:
      IllegalArgumentException - if the name is not specified, or a top-level deployment node with the same name already exists in the model
    • addDeploymentNode

      @Nonnull public DeploymentNode addDeploymentNode(@Nullable String environment, @Nonnull String name, String description, String technology, int instances, Map<String,String> properties)
      Adds a top-level deployment node to this model.
      Parameters:
      environment - the name of the deployment environment
      name - the name of the deployment node
      description - the description of the deployment node
      technology - the technology associated with the deployment node
      instances - the number of instances of the deployment node
      properties - a map of name/value properties associated with the deployment node
      Returns:
      a DeploymentNode instance
      Throws:
      IllegalArgumentException - if the name is not specified, or a top-level deployment node with the same name already exists in the model
    • getDeploymentNodeWithName

      public DeploymentNode getDeploymentNodeWithName(String name)
      Gets the deployment node with the specified name and default environment.
      Parameters:
      name - the name of the deployment node
      Returns:
      the DeploymentNode instance with the specified name (or null if it doesn't exist).
    • getDeploymentNodeWithName

      public DeploymentNode getDeploymentNodeWithName(String name, String environment)
      Gets the deployment node with the specified name and environment.
      Parameters:
      name - the name of the deployment node
      environment - the name of the deployment environment
      Returns:
      the DeploymentNode instance with the specified name (or null if it doesn't exist).
    • getElementWithCanonicalName

      public Element getElementWithCanonicalName(String canonicalName)
      Gets the element with the specified canonical name.
      Parameters:
      canonicalName - the canonical name (e.g. /SoftwareSystem/Container)
      Returns:
      the Element with the given canonical name, or null if one doesn't exist
      Throws:
      IllegalArgumentException - if the canonical name is null or empty
    • setIdGenerator

      public void setIdGenerator(IdGenerator idGenerator)
      Sets the ID generator associated with this model.
      Parameters:
      idGenerator - an IdGenerate instance
      Throws:
      IllegalArgumentException - if the ID generator is null
    • modifyRelationship

      public void modifyRelationship(Relationship relationship, String description, String technology)
      Provides a way for the description and technology to be modified on an existing relationship.
      Parameters:
      relationship - a Relationship instance
      description - the new description
      technology - the new technology
    • getImpliedRelationshipsStrategy

      public ImpliedRelationshipsStrategy getImpliedRelationshipsStrategy()
      Gets the strategy in use for creating implied relationships.
      Returns:
      an ImpliedRelationshipStrategy implementation
    • setImpliedRelationshipsStrategy

      public void setImpliedRelationshipsStrategy(ImpliedRelationshipsStrategy impliedRelationshipStrategy)
      Sets the strategy is use for creating implied relationships.
      Parameters:
      impliedRelationshipStrategy - an ImpliedRelationshipStrategy implementation