Package com.structurizr.model
Class Container
java.lang.Object
com.structurizr.model.Element
com.structurizr.model.StaticStructureElement
com.structurizr.model.Container
public final class Container extends StaticStructureElement
Represents a "container" in the C4 model.
-
Method Summary
Modifier and Type Method Description ComponentaddComponent(java.lang.String name, java.lang.Class type, java.lang.String description, java.lang.String technology)Adds a component to this container.ComponentaddComponent(java.lang.String name, java.lang.String description)Adds a component to this container.ComponentaddComponent(java.lang.String name, java.lang.String description, java.lang.String technology)Adds a component to this container.ComponentaddComponent(java.lang.String name, java.lang.String type, java.lang.String description, java.lang.String technology)Adds a component to this container.PerspectiveaddPerspective(java.lang.String name, java.lang.String description)Adds a perspective to this model item.voidaddProperty(java.lang.String name, java.lang.String value)Adds a name-value pair property to this element.voidaddTags(java.lang.String... tags)java.lang.StringgetCanonicalName()Gets the canonical name of this container, in the form "/Software System/Container".ComponentgetComponentOfType(java.lang.String type)Gets the component of the specified type.java.util.Set<Component>getComponents()Gets the set of components within this software system.ComponentgetComponentWithName(java.lang.String name)Gets the component with the specified name.java.lang.StringgetId()Gets the ID of this item in the model.ElementgetParent()Gets the parent software system.java.util.Set<Perspective>getPerspectives()Gets the set of perspectives associated with this model item.java.util.Map<java.lang.String,java.lang.String>getProperties()Gets the collection of name-value property pairs associated with this element, as a Map.protected java.util.Set<java.lang.String>getRequiredTags()SoftwareSystemgetSoftwareSystem()Gets the parent software system.java.lang.StringgetTags()Gets the comma separated list of tags.java.util.Set<java.lang.String>getTagsAsSet()java.lang.StringgetTechnology()Gets the technology associated with this container (e.g.booleanhasTag(java.lang.String tag)Determines whether this model item has the given tag.booleanremoveTag(java.lang.String tag)Removes the given tag.voidsetTechnology(java.lang.String technology)Sets the technology associated with this container.Methods inherited from class com.structurizr.model.StaticStructureElement
delivers, delivers, delivers, uses, uses, uses, uses, uses, uses, uses, uses, uses, usesMethods inherited from class com.structurizr.model.Element
getDescription, getEfferentRelationshipWith, getModel, getName, getRelationships, getUrl, hasAfferentRelationships, hasEfferentRelationshipWith, setDescription, setModel, setUrl, toString
-
Method Details
-
getParent
Gets the parent software system. -
getSoftwareSystem
Gets the parent software system.- Returns:
- the parent SoftwareSystem instance
-
getTechnology
public java.lang.String getTechnology()Gets the technology associated with this container (e.g. "Spring MVC application").- Returns:
- the technology, as a String, or null if no technology has been specified
-
setTechnology
public void setTechnology(java.lang.String technology)Sets the technology associated with this container.- Parameters:
technology- the technology, as a String
-
addComponent
Adds a component to this container.- Parameters:
name- the name of the componentdescription- a description of the component- Returns:
- the resulting Component instance
- Throws:
java.lang.IllegalArgumentException- if the component name is null or empty, or a component with the same name already exists
-
addComponent
public Component addComponent(java.lang.String name, java.lang.String description, java.lang.String technology)Adds a component to this container.- Parameters:
name- the name of the componentdescription- a description of the componenttechnology- the technology of the component- Returns:
- the resulting Component instance
- Throws:
java.lang.IllegalArgumentException- if the component name is null or empty, or a component with the same name already exists
-
addComponent
public Component addComponent(java.lang.String name, java.lang.Class type, java.lang.String description, java.lang.String technology)Adds a component to this container.- Parameters:
name- the name of the componenttype- a Class instance representing the primary type of the componentdescription- a description of the componenttechnology- the technology of the component- Returns:
- the resulting Component instance
- Throws:
java.lang.IllegalArgumentException- if the component name is null or empty, or a component with the same name already exists
-
addComponent
public Component addComponent(java.lang.String name, java.lang.String type, java.lang.String description, java.lang.String technology)Adds a component to this container.- Parameters:
name- the name of the componenttype- a String describing the fully qualified name of the primary type of the componentdescription- a description of the componenttechnology- the technology of the component- Returns:
- the resulting Component instance
- Throws:
java.lang.IllegalArgumentException- if the component name is null or empty, or a component with the same name already exists
-
getComponents
Gets the set of components within this software system.- Returns:
- a Set of Component objects
-
getComponentWithName
Gets the component with the specified name.- Parameters:
name- the name of the component- Returns:
- the Component instance, or null if a component with the specified name does not exist
- Throws:
java.lang.IllegalArgumentException- if the name is null or empty
-
getComponentOfType
Gets the component of the specified type.- Parameters:
type- the fully qualified type of the component- Returns:
- the Component instance, or null if a component with the specified type does not exist
- Throws:
java.lang.IllegalArgumentException- if the type is null or empty
-
getCanonicalName
public java.lang.String getCanonicalName()Gets the canonical name of this container, in the form "/Software System/Container".- Specified by:
getCanonicalNamein classElement- Returns:
- the canonical name, as a String
-
getRequiredTags
protected java.util.Set<java.lang.String> getRequiredTags() -
getId
public java.lang.String getId()Gets the ID of this item in the model.- Returns:
- the ID, as a String
-
getTags
public java.lang.String getTags()Gets the comma separated list of tags.- Returns:
- a comma separated list of tags, or an empty string if there are no tags
-
getTagsAsSet
public java.util.Set<java.lang.String> getTagsAsSet() -
addTags
public void addTags(java.lang.String... tags) -
removeTag
public boolean removeTag(java.lang.String tag)Removes the given tag.- Parameters:
tag- the tag to remove- Returns:
- true if the tag was removed; will return false if a non-existent tag is passed, or if an attempt is made to remove required tags, which cannot be removed.
-
hasTag
public boolean hasTag(java.lang.String tag)Determines whether this model item has the given tag.- Parameters:
tag- the tag to check for- Returns:
- true if tag is present as a tag on this item, or if it is one of the required tags defined by the model in getRequiredTags(), false otherwise
-
getProperties
public java.util.Map<java.lang.String,java.lang.String> getProperties()Gets the collection of name-value property pairs associated with this element, as a Map.- Returns:
- a Map (String, String) (empty if there are no properties)
-
addProperty
public void addProperty(java.lang.String name, java.lang.String value)Adds a name-value pair property to this element.- Parameters:
name- the name of the propertyvalue- the value of the property
-
getPerspectives
Gets the set of perspectives associated with this model item.- Returns:
- a Set of Perspective objects (empty if there are none)
-
addPerspective
Adds a perspective to this model item.- Parameters:
name- the name of the perspective (e.g. "Security", must be unique)description- a description of the perspective- Returns:
- a Perspective object
- Throws:
java.lang.IllegalArgumentException- if perspective details are not specified, or the named perspective exists already
-