Class M3Node<T extends M3Node>

All Implemented Interfaces:
ClassifierInstance<Concept>, HasFeatureValues, Node
Direct Known Subclasses:
EnumerationLiteral, Feature, Field, Language, LanguageEntity

public abstract class M3Node<T extends M3Node> extends AbstractClassifierInstance<Concept> implements Node
Base class to help implements Node in the language package.

Other libraries could implement Node differently, for example based on reflection. However, this is outside the scope of this library. This library should provide a solid, basic dependency to be used by other implementation and it should be as reusable, basic, and unopinionated as possible.

Each M3Node is connected to a specific version of lionWebVersion, as these elements may behave differently depending on the version of LionWeb they are representing.

  • Constructor Details

    • M3Node

      protected M3Node()
    • M3Node

      protected M3Node(@Nonnull LionWebVersion lionWebVersion)
  • Method Details

    • setID

      public T setID(String id)
    • setParent

      public T setParent(Node parent)
    • getRoot

      public Node getRoot()
      Description copied from interface: Node
      If a Node is a root node in a Model, this method returns the node itself. Otherwise it returns the ancestor which is a root node. This method should return null only if the Node is not inserted in a Model and it is therefore considered a dangling Node.
      Specified by:
      getRoot in interface Node
    • getParent

      public Node getParent()
      Description copied from interface: ClassifierInstance
      The immediate parent of the Node. This should be null only for root nodes.
      Specified by:
      getParent in interface ClassifierInstance<T extends M3Node>
      Specified by:
      getParent in interface Node
    • getContainmentFeature

      public Containment getContainmentFeature()
      Description copied from interface: Node
      Return the Containment feature used to hold this Node within its parent. This will be null only for root nodes or dangling nodes (which are not distinguishable by looking at the node itself).
      Specified by:
      getContainmentFeature in interface Node
      See Also:
    • getPropertyValue

      @Nullable public Object getPropertyValue(@Nonnull Property property)
      Description copied from interface: HasFeatureValues
      Get the property value associated with the specified property.
      Specified by:
      getPropertyValue in interface HasFeatureValues
    • getPropertyValue

      @Nullable protected <V> V getPropertyValue(@Nonnull String propertyName, @Nonnull Class<V> clazz, @Nullable V defaultValue)
      This internal method uses a property name and not a property or the property id because of a circular dependency problem present for nodes representing M3 elements.
    • getPropertyValue

      protected <V> V getPropertyValue(String propertyName, Class<V> clazz)
    • setPropertyValue

      public void setPropertyValue(@Nonnull Property property, @Nullable Object value)
      Specified by:
      setPropertyValue in interface HasFeatureValues
    • setPropertyValue

      protected void setPropertyValue(String propertyName, Object value)
    • getChildren

      @Nonnull public List<Node> getChildren(@Nonnull Containment containment)
      Description copied from interface: HasFeatureValues
      This return all the Nodes directly contained into this Node under the specific Containment relation specified.
      Specified by:
      getChildren in interface HasFeatureValues
    • addChild

      public void addChild(@Nonnull Containment containment, @Nonnull Node child)
      Description copied from interface: HasFeatureValues
      Add a child to the specified list of children associated with the given Containment relation. If the specified Containment does not allow for multiple values, and if a value is already set than the exception IllegalStateException will be thrown.

      If the child has not a Concept compatible with the target of the Containement, the exception IllegalArgumentException will be thrown.

      Specified by:
      addChild in interface HasFeatureValues
    • removeChild

      public void removeChild(@Nonnull Node child)
      Description copied from interface: HasFeatureValues
      Remove the given child from the list of children associated with the Node, making it a dangling Node. If the specified Node is not currently a child of this Node the exception IllegalArgumentException will be thrown.
      Specified by:
      removeChild in interface HasFeatureValues
      Overrides:
      removeChild in class AbstractClassifierInstance<Concept>
    • getReferenceValues

      @Nonnull public List<ReferenceValue> getReferenceValues(@Nonnull Reference reference)
      Specified by:
      getReferenceValues in interface HasFeatureValues
    • addReferenceValue

      public void addReferenceValue(@Nonnull Reference reference, @Nullable ReferenceValue referenceValue)
      Description copied from interface: HasFeatureValues
      Add the Node to the list of Nodes referred to from this Node under the given Reference.

      If the Reference is not multiple, any previous value will be replaced.

      The Node specified should be either part of this Node's Model or of Models imported by this Node's Model. If that is not the case the exception IllegalArgumentException will be thrown.

      If the referredNode has not a Concept compatible with the target of the Reference, the exception IllegalArgumentException will be thrown.

      Specified by:
      addReferenceValue in interface HasFeatureValues
    • setReferenceValues

      public void setReferenceValues(@Nonnull Reference reference, @Nonnull List<? extends ReferenceValue> values)
      Specified by:
      setReferenceValues in interface HasFeatureValues
    • getID

      @Nullable public String getID()
      Description copied from interface: Node
      This return the Node ID.

      A valid Node ID should not be null, but this method can return a null value in case the Node is in invalid state.

      Specified by:
      getID in interface ClassifierInstance<T extends M3Node>
      Specified by:
      getID in interface Node
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getContainmentSingleValue

      protected <V extends Node> V getContainmentSingleValue(String linkName)
    • getReferenceSingleValue

      protected <V extends Node> V getReferenceSingleValue(String linkName)
    • getContainmentMultipleValue

      protected <V extends Node> List<V> getContainmentMultipleValue(String linkName)
    • getReferenceMultipleValue

      protected <V extends Node> List<V> getReferenceMultipleValue(String linkName)
    • setReferenceSingleValue

      protected void setReferenceSingleValue(@Nonnull String linkName, @Nullable ReferenceValue value)
    • addContainmentMultipleValue

      protected boolean addContainmentMultipleValue(@Nonnull String linkName, Node value)
      Adding a null value or a value already contained, do not produce any change.
      Returns:
      return true if the addition produced a change
    • addReferenceMultipleValue

      protected void addReferenceMultipleValue(String linkName, ReferenceValue value)
    • getLionWebVersion

      @Nonnull public LionWebVersion getLionWebVersion()
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object