Index: NodeReferencesId.java
===================================================================
--- NodeReferencesId.java (revision 380133)
+++ NodeReferencesId.java (working copy)
@@ -22,27 +22,55 @@
/**
* Identifies a NodeReferences object.
*/
-public class NodeReferencesId extends NodeId {
+public class NodeReferencesId {
/**
+ * The id of the target node.
+ */
+ private final NodeId id;
+
+ /**
* Create a new instance of this class. Takes a UUID as parameter.
*
* @param uuid uuid of target node
+ * @throws IllegalArgumentException if uuid is null.
*/
public NodeReferencesId(UUID uuid) {
- super(uuid);
+ id = new NodeId(uuid);
}
/**
* Create a new instance of this class. Takes a id as parameter.
*
* @param id the id of target node
+ * @throws IllegalArgumentException if id is null.
*/
public NodeReferencesId(NodeId id) {
- super(id == null ? null : id.getUUID());
+ if (id == null) {
+ throw new IllegalArgumentException("id must not be null");
+ }
+ this.id = id;
}
/**
+ * Returns the id of the target node.
+ *
+ * @return the id of the target node.
+ */
+ public NodeId getTargetNodeId() {
+ return id;
+ }
+
+ /**
+ * Return the UUID of the target id
+ *
+ * @return UUID of the target id
+ */
+ public UUID getUUID() {
+ return id.getUUID();
+ }
+
+ /**
* Returns a NodeReferencesId holding the value of the specified
* string. The string must be in the format returned by the
* NodeReferencesId.toString() method.
@@ -54,11 +82,41 @@
* as a NodeReferencesId.
* @see #toString()
*/
- public static NodeId valueOf(String s) throws IllegalArgumentException {
+ public static NodeReferencesId valueOf(String s) throws IllegalArgumentException {
if (s == null) {
throw new IllegalArgumentException("invalid NodeReferencesId literal");
}
return new NodeReferencesId(NodeId.valueOf(s));
}
+ /**
+ * Returns the same as this.getTargetNodeId().toString().
+ *
+ * @return the same as this.getTargetNodeId().toString().
+ */
+ public String toString() {
+ return id.toString();
+ }
+
+ /**
+ * Returns the same as this.getTargetNodeId().hashCode().
+ *
+ * @return the same as this.getTargetNodeId().hashCode().
+ */
+ public int hashCode() {
+ return id.hashCode();
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof NodeReferencesId) {
+ return id.getUUID().equals(((NodeReferencesId) obj).id.getUUID());
+ }
+ return false;
+ }
}