From: David ‘Bombe’ Roden Date: Fri, 16 May 2008 14:18:35 +0000 (+0000) Subject: add property name constants X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=7f9181af9d0a8d419186b982060ec62f0f326493;p=jSite2.git add property name constants git-svn-id: http://trooper/svn/projects/jSite/trunk@892 c3eda9e8-030b-0410-8277-bc7414b0a119 --- diff --git a/src/net/pterodactylus/jsite/core/Node.java b/src/net/pterodactylus/jsite/core/Node.java index afcce6a..7751225 100644 --- a/src/net/pterodactylus/jsite/core/Node.java +++ b/src/net/pterodactylus/jsite/core/Node.java @@ -26,7 +26,8 @@ import java.util.Collections; import java.util.List; /** - * Container for a Freenet node. + * Container for a Freenet node. A Node is capable of notifying + * {@link PropertyChangeListener}s if any of the contained properties change. * * @author David ‘Bombe’ Roden <bombe@freenetproject.org> * @version $Id$ @@ -36,6 +37,15 @@ public class Node { /** Property change listeners. */ private final List propertyChangeListeners = Collections.synchronizedList(new ArrayList()); + /** Name of the “name” property. */ + public static final String PROPERTY_NAME = "name"; + + /** Name of the “hostname” property. */ + public static final String PROPERTY_HOSTNAME = "hostname"; + + /** Name of the “port” property. */ + public static final String PROPERTY_PORT = "port"; + /** The name of the node. */ private String name; @@ -110,7 +120,7 @@ public class Node { String oldName = this.name; this.name = name; if (((oldName != null) && (name == null)) || ((oldName == null) && (name != null)) || ((name != null) && !name.equals(oldName))) { - firePropertyChange("name", oldName, name); + firePropertyChange(PROPERTY_NAME, oldName, name); } } @@ -133,7 +143,7 @@ public class Node { String oldHostname = this.hostname; this.hostname = hostname; if (((oldHostname != null) && (hostname == null)) || ((oldHostname == null) && (hostname != null)) || ((hostname != null) && !hostname.equals(oldHostname))) { - firePropertyChange("hostname", oldHostname, hostname); + firePropertyChange(PROPERTY_HOSTNAME, oldHostname, hostname); } } @@ -156,31 +166,10 @@ public class Node { int oldPort = this.port; this.port = port; if (oldPort != port) { - firePropertyChange("port", oldPort, port); + firePropertyChange(PROPERTY_PORT, oldPort, port); } } -// /** -// * {@inheritDoc} Two Node objects are considered equal if their hostnames -// * and their port numbers are equal. -// */ -// @Override -// public boolean equals(Object object) { -// if ((object == null) || !(object instanceof Node)) { -// return false; -// } -// Node node = (Node) object; -// return hostname.equals(node.hostname) && port == node.port; -// } - -// /** -// * {@inheritDoc} -// */ -// @Override -// public int hashCode() { -// return hostname.hashCode() ^ (-1 - port); -// } - /** * {@inheritDoc} */