gumbo.util.relation
Class Connection

java.lang.Object
  |
  +--gumbo.util.AbstractDisposable
        |
        +--gumbo.util.relation.Connection
All Implemented Interfaces:
Disposable
Direct Known Subclasses:
TestConnection, TreeNodeConnection

public abstract class Connection
extends AbstractDisposable

Abstract base class for reporting connection changes between relations in a relationship. Includes the relationship and a list of relations involved in the connection. Concrete subclasses should define the order and semantics of the connection relations. By definition, a connection involves two or more relations, all of which are in the same relationship. If self-connection is allowed the connection relations and their delegators may not be unique.

Version:
$Revision: 1.2 $
Author:
Jon Barrilleaux (jonb@jmbaai.com) of JMB and Associates Inc.

Constructor Summary
Connection()
          Creates a new instance with no relationship or relations, which is an invalid state.
Connection(Connection connection)
          Creates a new instance as a shallow copy of a connection.
Connection(java.util.List relations)
          Creates a new instance.
Connection(Relationship relationship, java.util.List delegators)
          Creates a new instance.
 
Method Summary
 java.util.List getDelegators()
          Convenience method that gets an immutable snapshot of the delegators of this connection's relations, which are non-null.
 java.util.List getRelations()
          Gets an immutable snapshot of this connection's relations, which are non-null.
 Relationship getRelationship()
          Gets this conection's relationship.
protected  void implDispose()
          Nulls the relationship and relations.
protected  void setDelegators(Relationship relationship, java.util.List delegators)
          Convenience method that sets this connection's state using delegators instead of relations.
protected  void setRelations(java.util.List relations)
          Sets this connection's state.
 java.lang.String toString()
           
 
Methods inherited from class gumbo.util.AbstractDisposable
dispose, isDisposed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Connection

public Connection()
Creates a new instance with no relationship or relations, which is an invalid state. A valid state must be established using setConnection() before using this connection. Master constructor.


Connection

public Connection(Connection connection)
Creates a new instance as a shallow copy of a connection.


Connection

public Connection(java.util.List relations)
Creates a new instance. Master constructor.

Parameters:
relations - The ordered relations (Relation) in this connection. Never null, size >= 2, and all must be in the same relationship.

Connection

public Connection(Relationship relationship,
                  java.util.List delegators)
Creates a new instance. Master constructor.

Parameters:
relationship - The connection relationship. Never null.
delegators - The ordered delegators (Object) of the relations in this connection. Never null, size >= 2, and all must be in the same relationship.
Method Detail

getRelationship

public final Relationship getRelationship()
Gets this conection's relationship.

Returns:
Reference to the relationship. Invalid connection if null.

getRelations

public final java.util.List getRelations()
Gets an immutable snapshot of this connection's relations, which are non-null.

Returns:
The snapshot (use or save it immediately). Never null.

getDelegators

public final java.util.List getDelegators()
Convenience method that gets an immutable snapshot of the delegators of this connection's relations, which are non-null.

Returns:
The snapshot (use or save it immediately). Never null.

setRelations

protected final void setRelations(java.util.List relations)
Sets this connection's state.

Parameters:
relations - The ordered relations (Relation) in this connection. Never null, size >= 2, and all must be in the same relationship.

setDelegators

protected final void setDelegators(Relationship relationship,
                                   java.util.List delegators)
Convenience method that sets this connection's state using delegators instead of relations.

Parameters:
relationship - The connection relationship. Never null.
delegators - The ordered delegators (Object) of the relations in this connection. Never null, size >= 2, and all must be in the same relationship.

implDispose

protected void implDispose()
Nulls the relationship and relations.

Specified by:
implDispose in class AbstractDisposable

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object