Interface Connection

All Known Implementing Classes:
AbstractConnection, AbstractStrongReferencingConnection, GraphLayoutConnection

public interface Connection
A connection describes a relation between objects. The connection keeps a number of weak references between the objects in the relation. Each object should have a label describing the role of the object in the relation. These roles are unique Note that for all implementations of Connection, it is essential to consider memory consumption. Connections are kept in the framework for as long as the isRemoved() method returns false, hence this method should return true at the earliest occasion. All implementations of this class should carry the following annotations:
Author:
bfvdonge
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    containsObjects(Object... objects)
    Return true if all objects given as parameter are contained in the connection.
    boolean
    Return true if all objects given as parameter are contained in the connection.
    Return the ID of the connection.
    Return the label of the connection
    Return all objects contained in this connection, without their labels.
    <T> T
    Return the object with the given role in this connection The type of the returned object is T.
    Return the roles of all objects in this connection
    boolean
    Return true if one of the objects connected by this connection no longer exists, i.e.
    void
    Removes the connection.
    void
    sets the label of the connection to the new name
    void
    Sets the manager for the connection.
    void
    This method should be called as soon as the connection is changed, for example if the label changed, or if the contents of one of the connected objects changes.
  • Method Details

    • getLabel

      String getLabel()
      Return the label of the connection
      Returns:
    • getID

      ConnectionID getID()
      Return the ID of the connection.
      Returns:
    • containsObjects

      boolean containsObjects(Object... objects)
      Return true if all objects given as parameter are contained in the connection. Multiplicities are taken into account, however order is abstracted from
      Parameters:
      objects - the objects to check for
      Returns:
    • containsObjects

      boolean containsObjects(Collection<?> objects)
      Return true if all objects given as parameter are contained in the connection. Multiplicities are taken into account, i.e. each object should occur as often as it is returned by the iterator of the given collection however order is abstracted from
      Parameters:
      objects - the objects as a collection
      Returns:
    • isRemoved

      boolean isRemoved()
      Return true if one of the objects connected by this connection no longer exists, i.e. it is collected by the garbage collector.
      Returns:
    • getObjects

      MultiSet<Object> getObjects()
      Return all objects contained in this connection, without their labels. By contract, this method should always return the same set of objects after the connections was created, i.e. connections may only be changed by changing the contents of the objects, but not by changing the pointers.
      Returns:
    • getRoles

      Set<String> getRoles()
      Return the roles of all objects in this connection
      Returns:
    • getObjectWithRole

      <T> T getObjectWithRole(String role)
      Return the object with the given role in this connection The type of the returned object is T. However, no checks have to be performed to see if the cast can be made. It is up to the calling method to ensure this cast is safe.
      Type Parameters:
      T - The type of object that should be returned.
      Parameters:
      role - the role the returned object has to have
      Returns:
      the object attached to this role (not null).
    • remove

      void remove()
      Removes the connection. After calling this method, isRemoved()returns true;
    • setLabel

      void setLabel(String name)
      sets the label of the connection to the new name
      Parameters:
      name -
    • updated

      void updated()
      This method should be called as soon as the connection is changed, for example if the label changed, or if the contents of one of the connected objects changes. By calling this method, the connection manager should be notified.
    • setManager

      void setManager(ConnectionManager manager)
      Sets the manager for the connection. This method is called by the connection manager as soon as this connection is added to that manager. A connection should keep a reference to the manager only in a transient field.
      Parameters:
      manager -