Package com.structurizr.model
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 Summary
Modifier and Type Method Description DeploymentNodeaddDeploymentNode(java.lang.String name, java.lang.String description, java.lang.String technology)Adds a top-level deployment node to this model.DeploymentNodeaddDeploymentNode(java.lang.String name, java.lang.String description, java.lang.String technology, int instances)Adds a top-level deployment node to this model.DeploymentNodeaddDeploymentNode(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.DeploymentNodeaddDeploymentNode(java.lang.String environment, java.lang.String name, java.lang.String description, java.lang.String technology)Adds a top-level deployment node to this model.DeploymentNodeaddDeploymentNode(java.lang.String environment, java.lang.String name, java.lang.String description, java.lang.String technology, int instances)Adds a top-level deployment node to this model.DeploymentNodeaddDeploymentNode(java.lang.String environment, 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.java.util.Set<Relationship>addImplicitRelationships()Propagates all relationships from children to their parents.PersonaddPerson(Location location, java.lang.String name, java.lang.String description)Creates a person and adds it to the model.PersonaddPerson(java.lang.String name, java.lang.String description)Creates a person (with an unspecified location) and adds it to the model.SoftwareSystemaddSoftwareSystem(Location location, java.lang.String name, java.lang.String description)Creates a software system and adds it to the model.SoftwareSystemaddSoftwareSystem(java.lang.String name, java.lang.String description)Creates a software system (with an unspecified location) and adds it to the model.booleancontains(Element element)Determines whether this model contains the specified element.java.util.Set<DeploymentNode>getDeploymentNodes()Gets the set of all top-level deployment nodes in this model.DeploymentNodegetDeploymentNodeWithName(java.lang.String name)Gets the deployment node with the specified name and default environment.DeploymentNodegetDeploymentNodeWithName(java.lang.String name, java.lang.String environment)Gets the deployment node with the specified name and environment.ElementgetElement(java.lang.String id)Gets the element with the specified ID.java.util.Set<Element>getElements()Gets the set of all elements in this model.ElementgetElementWithCanonicalName(java.lang.String canonicalName)Gets the element with the specified canonical name.EnterprisegetEnterprise()Gets the enterprise associated with this model.java.util.Set<Person>getPeople()Gets the set of all people in this model.PersongetPersonWithName(java.lang.String name)Gets the person with the specified name.RelationshipgetRelationship(java.lang.String id)Gets the relationship with the specified ID.java.util.Set<Relationship>getRelationships()Gets the set of all relationships in this model.java.util.Set<SoftwareSystem>getSoftwareSystems()Gets the set of all software systems in this model.SoftwareSystemgetSoftwareSystemWithId(java.lang.String id)Gets the software system with the specified ID.SoftwareSystemgetSoftwareSystemWithName(java.lang.String name)Gets the software system with the specified name.booleanisEmpty()Determines whether this model is empty.voidmodifyRelationship(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.voidsetEnterprise(Enterprise enterprise)Sets the enterprise associated with this model.voidsetIdGenerator(IdGenerator idGenerator)Sets the ID generator associated with this model.
-
Method Details
-
getEnterprise
Gets the enterprise associated with this model.- Returns:
- an Enterprise instance, or null if one has not been set
-
setEnterprise
Sets the enterprise associated with this model.- Parameters:
enterprise- an Enterprise instance
-
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 systemdescription- 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 systemdescription- 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, @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
Gets the set of all elements in this model.- Returns:
- a Set of Element instances
-
getElement
Gets the element with the specified ID.- Parameters:
id- theModelItem.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
Gets the set of all relationships in this model.- Returns:
- a Set of Relationship objects
-
getRelationship
Gets the relationship with the specified ID.- Parameters:
id- theModelItem.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
Gets the set of all people in this model.- Returns:
- a Set of Person instances
-
getSoftwareSystems
Gets the set of all software systems in this model.- Returns:
- a Set of SoftwareSystem instances
-
getDeploymentNodes
Gets the set of all top-level deployment nodes in this model.- Returns:
- a Set of DeploymentNode instances
-
contains
Determines whether this model contains the specified element.- Parameters:
element- any element- Returns:
- true, if the element is contained in this model
-
getSoftwareSystemWithName
Gets the software system with the specified name.- Parameters:
name- the name of aSoftwareSystem- 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
Gets the software system with the specified ID.- Parameters:
id- theModelItem.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
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
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, @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 nodedescription- the description of the deployment nodetechnology- 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 environmentname- the name of the deployment nodedescription- the description of the deployment nodetechnology- 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 nodedescription- the description of the deployment nodetechnology- the technology associated with the deployment nodeinstances- 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 environmentname- the name of the deployment nodedescription- the description of the deployment nodetechnology- the technology associated with the deployment nodeinstances- 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 nodedescription- the description of the deployment nodetechnology- the technology associated with the deployment nodeinstances- the number of instances of the deployment nodeproperties- 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 environmentname- the name of the deployment nodedescription- the description of the deployment nodetechnology- the technology associated with the deployment nodeinstances- the number of instances of the deployment nodeproperties- 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
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 nodeenvironment- the name of the deployment environment- Returns:
- the DeploymentNode instance with the specified name (or null if it doesn't exist).
-
getElementWithCanonicalName
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
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 instancedescription- the new descriptiontechnology- the new technology
-