Package com.structurizr.model
Class Element
java.lang.Object
com.structurizr.model.Element
- Direct Known Subclasses:
DeploymentElement
,StaticStructureElement
public abstract class Element
extends java.lang.Object
This is the superclass for all model elements.
-
Constructor Summary
Constructors Modifier Constructor Description protected
Element()
-
Method Summary
Modifier and Type Method Description Perspective
addPerspective(java.lang.String name, java.lang.String description)
Adds a perspective to this model item.void
addProperty(java.lang.String name, java.lang.String value)
Adds a name-value pair property to this element.void
addTags(java.lang.String... tags)
abstract java.lang.String
getCanonicalName()
java.lang.String
getDescription()
Gets a description of this element.Relationship
getEfferentRelationshipWith(Element element)
Gets the efferent (outgoing) relationship with the specified element.java.lang.String
getId()
Gets the ID of this item in the model.Model
getModel()
java.lang.String
getName()
Gets the name of this element.abstract Element
getParent()
Gets the parent of this element.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.java.util.Set<Relationship>
getRelationships()
Gets the set of outgoing relationships.protected abstract java.util.Set<java.lang.String>
getRequiredTags()
java.lang.String
getTags()
Gets the comma separated list of tags.java.util.Set<java.lang.String>
getTagsAsSet()
java.lang.String
getUrl()
Gets the URL where more information about this element can be found.boolean
hasAfferentRelationships()
Determines whether this element has afferent (incoming) relationships.boolean
hasEfferentRelationshipWith(Element element)
Determines whether this element has an efferent (outgoing) relationship with the specified element.boolean
hasTag(java.lang.String tag)
Determines whether this model item has the given tag.boolean
removeTag(java.lang.String tag)
Removes the given tag.void
setDescription(java.lang.String description)
Sets the description of this element.protected void
setModel(Model model)
void
setUrl(java.lang.String url)
Sets the URL where more information about this element can be found.java.lang.String
toString()
-
Constructor Details
-
Element
protected Element()
-
-
Method Details
-
getModel
-
setModel
-
getName
public java.lang.String getName()Gets the name of this element.- Returns:
- the name, as a String
-
getUrl
public java.lang.String getUrl()Gets the URL where more information about this element can be found.- Returns:
- a URL as a String
-
setUrl
public void setUrl(java.lang.String url)Sets the URL where more information about this element can be found.- Parameters:
url
- the URL as a String- Throws:
java.lang.IllegalArgumentException
- if the URL is not a well-formed URL
-
getCanonicalName
public abstract java.lang.String getCanonicalName() -
getDescription
public java.lang.String getDescription()Gets a description of this element.- Returns:
- the description, as a String
-
setDescription
public void setDescription(java.lang.String description)Sets the description of this element.- Parameters:
description
- the description, as a String
-
getParent
Gets the parent of this element.- Returns:
- the parent Element, or null if this element doesn't have a parent (i.e. a Person or SoftwareSystem)
-
getRelationships
Gets the set of outgoing relationships.- Returns:
- a Set of Relationship objects, or an empty set if none exist
-
hasAfferentRelationships
public boolean hasAfferentRelationships()Determines whether this element has afferent (incoming) relationships.- Returns:
- true if this element has afferent relationships, false otherwise
-
hasEfferentRelationshipWith
Determines whether this element has an efferent (outgoing) relationship with the specified element.- Parameters:
element
- the element to look for- Returns:
- true if this element has an efferent relationship with the specified element, false otherwise
-
getEfferentRelationshipWith
Gets the efferent (outgoing) relationship with the specified element.- Parameters:
element
- the element to look for- Returns:
- a Relationship object if an efferent relationship exists, null otherwise
-
toString
public java.lang.String toString()- Overrides:
toString
in classjava.lang.Object
-
getRequiredTags
protected abstract 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
-