package net.pterodactylus.jsite.core;
-import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import net.pterodactylus.util.beans.Comparer;
+import net.pterodactylus.util.beans.AbstractBean;
/**
* Container for project information. A Project is capable of notifying
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
* @version $Id$
*/
-public class Project {
-
- /** Property change listeners. */
- private final List<PropertyChangeListener> propertyChangeListeners = Collections.synchronizedList(new ArrayList<PropertyChangeListener>());
+public class Project extends
+AbstractBean {
/** Name of the “name” property. */
public static final String PROPERTY_NAME = "name";
//
/**
- * Adds a property change listener.
- *
- * @param propertyChangeListener
- * The property change listener to add
- */
- public void addPropertyChangeListener(PropertyChangeListener propertyChangeListener) {
- propertyChangeListeners.add(propertyChangeListener);
- }
-
- /**
- * Removes a property change listener.
- *
- * @param propertyChangeListener
- * The property change listener to remove
- */
- public void removePropertyChangeListener(PropertyChangeListener propertyChangeListener) {
- propertyChangeListeners.remove(propertyChangeListener);
- }
-
- /**
- * Notifies all listeners that a property has changed.
- *
- * @param property
- * The name of the property
- * @param oldValue
- * The old value of the property
- * @param newValue
- * The new value of the property
- */
- private void firePropertyChange(String property, Object oldValue, Object newValue) {
- PropertyChangeEvent propertyChangeEvent = new PropertyChangeEvent(this, property, oldValue, newValue);
- for (PropertyChangeListener propertyChangeListener: propertyChangeListeners) {
- propertyChangeListener.propertyChange(propertyChangeEvent);
- }
-
- }
-
- //
- // ACCESSORS
- //
-
- /**
* Returns the name of the project.
*
* @return The name of the project
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);
}
}