Package org.jcsp.net

Class NodeUI

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable
    Direct Known Subclasses:
    NodeUIImpl

    public abstract class NodeUI
    extends java.lang.Object
    implements java.io.Serializable, java.lang.Comparable

    A Unique Identifier for a Node. This class is different from NodeID in that it does not describe the Node's location.

    Implementations of this class should provide a constructor that takes a String parameter which is in the format of the String returned from the getImplStringForm() method.

    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      NodeUI()  
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected abstract boolean checkEqual​(NodeUI other)
      An abstract method to be implemented to return whether another NodeUI object is equal to this instance.
      int compareTo​(java.lang.Object o)
      Compares this NodeUI with another object.
      static NodeUI createFromStringForm​(java.lang.String stringForm)
      Creates a NodeUI from a String in the format of that returned from the getImplStringForm() method.
      boolean equals​(java.lang.Object o)
      Compares this NodeUI with another object.
      protected abstract java.lang.String getComparisonString()
      This is an abstract method that should be implemented to return a String that can be used by the compareTo(Object) method in order to compare two NodeUI objects.
      protected abstract java.lang.String getImplStringForm()
      Returns a String that can be supplied to the static createFromStringForm(String) method in order to create an equal NodeUI object.
      (package private) java.lang.String getStringForm()  
      abstract int hashCode()
      Returns an int hash code for this object.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • NodeUI

        public NodeUI()
    • Method Detail

      • getStringForm

        final java.lang.String getStringForm()
      • getImplStringForm

        protected abstract java.lang.String getImplStringForm()
        Returns a String that can be supplied to the static createFromStringForm(String) method in order to create an equal NodeUI object.
        Returns:
        a String containing the necessary information to recreate this NodeUI object.
      • createFromStringForm

        public static final NodeUI createFromStringForm​(java.lang.String stringForm)
        Creates a NodeUI from a String in the format of that returned from the getImplStringForm() method.
        Parameters:
        stringForm - the String to use in creating the NodeUI object.
        Returns:
        a newly created NodeUI object.
      • equals

        public final boolean equals​(java.lang.Object o)
        Compares this NodeUI with another object. This method checks that the supplied object is a NodeUI object and then calls the implementation of the checkEqual(NodeUI) method and returns its result value as the result of this method.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        o - an object to compare with this object.
        Returns:
        true iff the supplied object is a NodeUI and the result of a call to the checkEqual(NodeUI) method is true.
      • compareTo

        public final int compareTo​(java.lang.Object o)
                            throws java.lang.ClassCastException
        Compares this NodeUI with another object. This method calls the implementation of the getComparisonString() method on both this NodeUI object and the NodeUI object supplied. The String class' compareTo(Object) is used to perform the comparison. The method is called on the String returned by this object and the String returned by the other object is supplied as the parameter.
        Specified by:
        compareTo in interface java.lang.Comparable
        Parameters:
        o - another object to compare with this object.
        Returns:
        an int value that follows the rules of the compareTo(Object) method in the String class.
        Throws:
        java.lang.ClassCastException - if the supplied object is not a NodeUI object.
      • checkEqual

        protected abstract boolean checkEqual​(NodeUI other)
        An abstract method to be implemented to return whether another NodeUI object is equal to this instance. If the the NodeUI is of a different implementation class, the method should return false.
        Parameters:
        other - a NodeUI to compare with this NodeUI.
        Returns:
        true iff the supplied NodeUI is equal to this one.
      • getComparisonString

        protected abstract java.lang.String getComparisonString()
        This is an abstract method that should be implemented to return a String that can be used by the compareTo(Object) method in order to compare two NodeUI objects. Two NodeUI objects should return equal String objects iff the two NodeUI objects are equal.
        Returns:
        a String that follows the above rules.
      • hashCode

        public abstract int hashCode()
        Returns an int hash code for this object. Two NodeUI objects will return equal hash codes if the two objects are equal.
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        an int hash code.