import java.beans.PropertyChangeListener;
import net.pterodactylus.util.beans.AbstractBean;
-import net.pterodactylus.util.beans.Comparer;
/**
* Container for a Freenet node. A Node is capable of notifying
public void setName(String name) {
String oldName = this.name;
this.name = name;
- if (!Comparer.equal(oldName, name)) {
+ if (!equal(oldName, name)) {
firePropertyChange(PROPERTY_NAME, oldName, name);
}
}
public void setHostname(String hostname) {
String oldHostname = this.hostname;
this.hostname = hostname;
- if (!Comparer.equal(oldHostname, hostname)) {
+ if (!equal(oldHostname, hostname)) {
firePropertyChange(PROPERTY_HOSTNAME, oldHostname, hostname);
}
}
import java.beans.PropertyChangeListener;
import net.pterodactylus.util.beans.AbstractBean;
-import net.pterodactylus.util.beans.Comparer;
/**
* Container for project information. A Project is capable of notifying
public void setName(String name) {
String oldName = this.name;
this.name = name;
- if (!Comparer.equal(oldName, name)) {
+ if (!equal(oldName, name)) {
firePropertyChange(PROPERTY_NAME, oldName, name);
}
}
public void setDescription(String description) {
String oldDescription = this.description;
this.description = description;
- if (!Comparer.equal(oldDescription, description)) {
+ if (!equal(oldDescription, description)) {
firePropertyChange(PROPERTY_DESCRIPTION, oldDescription, description);
}
}
public void setPublicKey(String publicKey) {
String oldPublicKey = this.publicKey;
this.publicKey = publicKey;
- if (!Comparer.equal(oldPublicKey, publicKey)) {
+ if (!equal(oldPublicKey, publicKey)) {
firePropertyChange(PROPERTY_PUBLIC_KEY, oldPublicKey, publicKey);
}
}
public void setPrivateKey(String privateKey) {
String oldPrivateKey = this.privateKey;
this.privateKey = privateKey;
- if (!Comparer.equal(oldPrivateKey, privateKey)) {
+ if (!equal(oldPrivateKey, privateKey)) {
firePropertyChange(PROPERTY_PRIVATE_KEY, oldPrivateKey, privateKey);
}
}
import net.pterodactylus.util.beans.AbstractBean;
-import net.pterodactylus.util.beans.Comparer;
/**
* A request is an ongoing download or upload reported by the freenet node.
public void setType(Type type) {
Type oldType = this.type;
this.type = type;
- if (!Comparer.equal(oldType, type)) {
+ if (!equal(oldType, type)) {
firePropertyChange(PROPERTY_TYPE, oldType, type);
}
}
public void setClientToken(String clientToken) {
String oldClientToken = this.clientToken;
this.clientToken = clientToken;
- if (!Comparer.equal(oldClientToken, clientToken)) {
+ if (!equal(oldClientToken, clientToken)) {
firePropertyChange(PROPERTY_CLIENT_TOKEN, oldClientToken, clientToken);
}
}
}
+ /**
+ * Compares the two objects and returns whether they are equal according to
+ * {@link Object#equals(Object)}. This method takes <code>null</code>
+ * into account as a valid value for an object.
+ *
+ * @param first
+ * The first object
+ * @param second
+ * The second object
+ * @return <code>true</code> if the two objects are equal,
+ * <code>false</code> otherwise
+ */
+ protected boolean equal(Object first, Object second) {
+ return ((first == null) && (second == null)) || ((first != null) && first.equals(second)) || ((second != null) && second.equals(first));
+ }
+
}
+++ /dev/null
-/*
- * jSite2 - StringComparer.java
- * Copyright © 2008 David Roden
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-package net.pterodactylus.util.beans;
-
-/**
- * Compares different objects. Can be used to detect change in property values.
- *
- * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
- * @version $Id$
- */
-public class Comparer {
-
- /**
- * Compares the two objects and returns whether they are equal according to
- * {@link Object#equals(Object)}. This method takes <code>null</code>
- * into account as a valid value for an object.
- *
- * @param first
- * The first object
- * @param second
- * The second object
- * @return <code>true</code> if the two objects are equal,
- * <code>false</code> otherwise
- */
- public static boolean equal(Object first, Object second) {
- return ((first == null) && (second == null)) || ((first != null) && first.equals(second)) || ((second != null) && second.equals(first));
- }
-
-}