org.progeeks.graph
Class ImmutableIdentityEdge

java.lang.Object
  extended by org.progeeks.graph.ImmutableIdentityEdge
All Implemented Interfaces:
com.phoenixst.plexus.Graph.Edge, java.io.Serializable

public class ImmutableIdentityEdge
extends java.lang.Object
implements com.phoenixst.plexus.Graph.Edge, java.io.Serializable

Graph.Edge that provides an immutable edge that uses its properties as its identity to implement .equals() and .hashCode(). Two ImmutableIdentityEdge instances with the same tail, head, user object, and direction will be considered the same edge. In the future, additional edge subclasses may provide additional immutable properties that allow for different edges containing the same properties listed above. This is a start down that path and will help keep many other places clean until then.

Version:
$Revision: 1.10 $
Author:
Paul Speed
See Also:
Serialized Form

Constructor Summary
ImmutableIdentityEdge(com.phoenixst.plexus.Graph.Edge edge)
          Creates a new edge with the same properties as the specified edge.
ImmutableIdentityEdge(java.lang.Object userObject, java.lang.Object tail, java.lang.Object head, boolean directed)
          Creates a new edge with the specified properties.
 
Method Summary
 boolean equals(java.lang.Object object)
          Returns true if the specified object is an ImmutableIdentityEdge that has the same tail, head, user object, and direction as this edge.
 java.lang.Object getHead()
           
 java.lang.Object getOtherEndpoint(java.lang.Object node)
           
 java.lang.Object getTail()
           
 java.lang.Object getUserObject()
           
 int hashCode()
          Returns a hash code value consistent with the .equals() implementation.
 boolean isDirected()
           
 void setUserObject(java.lang.Object object)
          Throws an UnsupportedOperationException because this edge implementation is immutable.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ImmutableIdentityEdge

public ImmutableIdentityEdge(java.lang.Object userObject,
                             java.lang.Object tail,
                             java.lang.Object head,
                             boolean directed)
Creates a new edge with the specified properties.


ImmutableIdentityEdge

public ImmutableIdentityEdge(com.phoenixst.plexus.Graph.Edge edge)
Creates a new edge with the same properties as the specified edge. This is useful in transformations or views that wrap a graph with unknown edge implementations but where the view must be edge-identity compatible.

Method Detail

isDirected

public boolean isDirected()
Specified by:
isDirected in interface com.phoenixst.plexus.Graph.Edge

getUserObject

public java.lang.Object getUserObject()
Specified by:
getUserObject in interface com.phoenixst.plexus.Graph.Edge

setUserObject

public void setUserObject(java.lang.Object object)
Throws an UnsupportedOperationException because this edge implementation is immutable.

Specified by:
setUserObject in interface com.phoenixst.plexus.Graph.Edge

getTail

public java.lang.Object getTail()
Specified by:
getTail in interface com.phoenixst.plexus.Graph.Edge

getHead

public java.lang.Object getHead()
Specified by:
getHead in interface com.phoenixst.plexus.Graph.Edge

getOtherEndpoint

public java.lang.Object getOtherEndpoint(java.lang.Object node)
Specified by:
getOtherEndpoint in interface com.phoenixst.plexus.Graph.Edge

equals

public boolean equals(java.lang.Object object)
Returns true if the specified object is an ImmutableIdentityEdge that has the same tail, head, user object, and direction as this edge. If the edges are not directed then their end-points are compared in a more free-form way allowing endpoints to be swapped but the edge still considered the same.

Specified by:
equals in interface com.phoenixst.plexus.Graph.Edge
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Returns a hash code value consistent with the .equals() implementation.

Specified by:
hashCode in interface com.phoenixst.plexus.Graph.Edge
Overrides:
hashCode in class java.lang.Object

toString

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


Copyright © 2002-2003 Paul Speed. All Rights Reserved.