Class Model

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

public final class Model
extends java.lang.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 java.lang.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:
      java.lang.IllegalArgumentException - if a software system with the same name already exists
    • addSoftwareSystem

      public SoftwareSystem addSoftwareSystem​(@Nonnull java.lang.String name, @Nullable java.lang.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:
      java.lang.IllegalArgumentException - if a software system with the same name already exists
    • addSoftwareSystem

      @Nonnull public SoftwareSystem addSoftwareSystem​(@Nullable Location location, @Nonnull java.lang.String name, @Nullable java.lang.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:
      java.lang.IllegalArgumentException - if a software system with the same name already exists
    • addPerson

      @Nonnull public Person addPerson​(@Nonnull java.lang.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:
      java.lang.IllegalArgumentException - if a person with the same name already exists
    • addPerson

      @Nonnull public Person addPerson​(@Nonnull java.lang.String name, @Nullable java.lang.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:
      java.lang.IllegalArgumentException - if a person with the same name already exists
    • addPerson

      @Nonnull public Person addPerson​(Location location, @Nonnull java.lang.String name, @Nullable java.lang.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:
      java.lang.IllegalArgumentException - if a person with the same name already exists
    • getElements

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

      @Nullable public Element getElement​(@Nonnull java.lang.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:
      ModelItem.getId()
    • getRelationships

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

      @Nullable public Relationship getRelationship​(@Nonnull java.lang.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:
      ModelItem.getId()
    • getPeople

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

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

      @Nonnull public java.util.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 java.lang.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:
      java.lang.IllegalArgumentException - if the name is null or empty
    • getSoftwareSystemWithId

      @Nullable public SoftwareSystem getSoftwareSystemWithId​(@Nonnull java.lang.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:
      java.lang.IllegalArgumentException - if the id is null or empty
      See Also:
      ModelItem.getId()
    • getPersonWithName

      @Nullable public Person getPersonWithName​(@Nonnull java.lang.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:
      java.lang.IllegalArgumentException - if the name is null or empty
    • addImplicitRelationships

      @Nonnull @Deprecated public java.util.Set<Relationship> addImplicitRelationships()
      Deprecated.
      use setImpliedRelationshipsStrategy(ImpliedRelationshipsStrategy) ()} instead to set a strategy, before creating relationships

      Propagates all relationships from children to their parents. For example, if you have two components (AAA and BBB) in different software systems that have a relationship, calling this method will add the following additional implied relationships to the model: AAA->BB AAA-->B AA->BBB AA->BB AA->B A->BBB A->BB A->B.

      Returns:
      a set of all implicit relationships that were added to the model
    • 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 java.lang.String name)
      Adds a top-level deployment node to this model.
      Parameters:
      name - the name of the deployment node
      Returns:
      a DeploymentNode instance
      Throws:
      java.lang.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 java.lang.String name, @Nullable java.lang.String description, @Nullable java.lang.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:
      java.lang.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 java.lang.String environment, @Nonnull java.lang.String name, @Nullable java.lang.String description, @Nullable java.lang.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:
      java.lang.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 java.lang.String name, @Nullable java.lang.String description, @Nullable java.lang.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:
      java.lang.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 java.lang.String environment, @Nonnull java.lang.String name, @Nullable java.lang.String description, @Nullable java.lang.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:
      java.lang.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 java.lang.String name, java.lang.String description, java.lang.String technology, int instances, java.util.Map<java.lang.String,​java.lang.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:
      java.lang.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 java.lang.String environment, @Nonnull java.lang.String name, java.lang.String description, java.lang.String technology, int instances, java.util.Map<java.lang.String,​java.lang.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:
      java.lang.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​(java.lang.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​(java.lang.String name, java.lang.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​(java.lang.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:
      java.lang.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:
      java.lang.IllegalArgumentException - if the ID generator is null
    • modifyRelationship

      public void modifyRelationship​(Relationship relationship, java.lang.String description, java.lang.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