Class AbstractConnection
java.lang.Object
org.processmining.framework.connections.impl.AbstractConnection
- All Implemented Interfaces:
Connection
- Direct Known Subclasses:
AbstractStrongReferencingConnection
,GraphLayoutConnection
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.
The AbstractConnection keeps weak references to the objects added through the
put methods. As soon as one of these objects is collected by the garbage
collector, then this connection becomes removed. Therefore, it is essential
that subclasses of the AbstractConnection do not keep pointers to these
objects, or at least only keep weak references.
This class is annotated with @ConnectionAnnotation. Therefore, none of the
implementing classes have to do so explicitly.
- Author:
- bfvdonge
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
containsObjects
(Object... objects) Return true if all objects given as parameter are contained in the connection.boolean
containsObjects
(Collection<?> objects) Return true if all objects given as parameter are contained in the connection.boolean
protected Object
getID()
Return the ID of the connection.getLabel()
Return the label of the connectionprotected Map<String,
WeakReference<?>> Return all objects contained in this connection, without their labels.<T> T
getObjectWithRole
(String role) Return the object with the given role in this connection The type of the returned object is T.getRoles()
Return the roles of all objects in this connectionint
hashCode()
boolean
Return true if one of the objects connected by this connection no longer exists, i.e.protected <T> WeakReference<T>
void
remove()
Removes the connection.protected void
void
sets the label of the connection to the new namevoid
setManager
(ConnectionManager manager) Sets the manager for the connection.toString()
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.
-
Field Details
-
manager
-
-
Constructor Details
-
AbstractConnection
-
-
Method Details
-
setManager
Description copied from interface:Connection
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.- Specified by:
setManager
in interfaceConnection
-
getLabel
Description copied from interface:Connection
Return the label of the connection- Specified by:
getLabel
in interfaceConnection
- Returns:
-
containsObjects
Description copied from interface:Connection
Return true if all objects given as parameter are contained in the connection. Multiplicities are taken into account, however order is abstracted from- Specified by:
containsObjects
in interfaceConnection
- Parameters:
objects
- the objects to check for- Returns:
-
containsObjects
Description copied from interface:Connection
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- Specified by:
containsObjects
in interfaceConnection
- Parameters:
objects
- the objects as a collection- Returns:
-
isRemoved
public boolean isRemoved()Description copied from interface:Connection
Return true if one of the objects connected by this connection no longer exists, i.e. it is collected by the garbage collector.- Specified by:
isRemoved
in interfaceConnection
- Returns:
-
toString
-
hashCode
public int hashCode() -
getObjects
Description copied from interface:Connection
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.- Specified by:
getObjects
in interfaceConnection
- Returns:
-
equals
-
getID
Description copied from interface:Connection
Return the ID of the connection.- Specified by:
getID
in interfaceConnection
- Returns:
-
getObjectWithRole
Description copied from interface:Connection
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.- Specified by:
getObjectWithRole
in interfaceConnection
- 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).
-
getRoles
Description copied from interface:Connection
Return the roles of all objects in this connection- Specified by:
getRoles
in interfaceConnection
- Returns:
-
put
-
remove
-
get
-
getMapping
-
remove
public void remove()Removes the connection. After calling this method, isRemoved()returns true;- Specified by:
remove
in interfaceConnection
-
setLabel
sets the label of the connection to the new name- Specified by:
setLabel
in interfaceConnection
- Parameters:
name
-
-
updated
public void updated()Description copied from interface:Connection
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.- Specified by:
updated
in interfaceConnection
-