Class ModelItem

java.lang.Object
com.structurizr.model.ModelItem
All Implemented Interfaces:
PropertyHolder
Direct Known Subclasses:
Element, Relationship

public abstract class ModelItem extends Object implements PropertyHolder
The base class for elements and relationships.
  • Constructor Details

    • ModelItem

      public ModelItem()
  • Method Details

    • getCanonicalName

      public abstract String getCanonicalName()
    • getDefaultTags

      public abstract Set<String> getDefaultTags()
    • getId

      public String getId()
      Gets the ID of this item in the model.
      Returns:
      the ID, as a String
    • getTags

      public 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 Set<String> getTagsAsSet()
    • addTags

      public void addTags(String... tags)
    • removeTag

      public boolean removeTag(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(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
    • getUrl

      public String getUrl()
      Gets the URL where more information about this item can be found.
      Returns:
      a URL as a String
    • setUrl

      public void setUrl(String url)
      Sets the URL where more information about this item can be found.
      Parameters:
      url - the URL as a String
      Throws:
      IllegalArgumentException - if the URL is not a well-formed URL
    • getProperties

      public Map<String,String> getProperties()
      Gets the collection of name-value property pairs associated with this model item, as a Map.
      Specified by:
      getProperties in interface PropertyHolder
      Returns:
      a Map (String, String) (empty if there are no properties)
    • addProperty

      public void addProperty(String name, String value)
      Adds a name-value pair property to this model item.
      Specified by:
      addProperty in interface PropertyHolder
      Parameters:
      name - the name of the property
      value - the value of the property
    • getPerspectives

      public Set<Perspective> getPerspectives()
      Gets the set of perspectives associated with this model item.
      Returns:
      a Set of Perspective objects (empty if there are none)
    • addPerspective

      public Perspective addPerspective(String name, String description)
      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:
      IllegalArgumentException - if perspective details are not specified, or the named perspective exists already