package net.pterodactylus.jsite.core;
+import java.beans.PropertyChangeListener;
+
+import net.pterodactylus.util.beans.AbstractBean;
+
/**
- * Container for project information.
+ * Container for project information. A Project is capable of notifying
+ * {@link PropertyChangeListener}s if any of the contained properties change.
*
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
* @version $Id$
*/
-public class Project {
+public class Project extends
+AbstractBean {
+
+ /** Name of the “name” property. */
+ public static final String PROPERTY_NAME = "name";
+
+ /** Name of the “description” property. */
+ public static final String PROPERTY_DESCRIPTION = "description";
+
+ /** Name of the “public key” property. */
+ public static final String PROPERTY_PUBLIC_KEY = "publicKey";
+
+ /** Name of the “private key” property. */
+ public static final String PROPERTY_PRIVATE_KEY = "privateKey";
+
+ /** Name of the “local path” property. */
+ public static final String PROPERTY_LOCAL_PATH = "localPath";
/** The name of the project. */
private String name;
- /** The local path of the project. */
- private String localPath;
+ /** The description of the project. */
+ private String description;
/** The public key. */
private String publicKey;
/** The private key. */
private String privateKey;
+ /** The local path of the project. */
+ private String localPath;
+
+ //
+ // EVENT MANAGEMENT
+ //
+
/**
* Returns the name of the project.
*
* The name of the project
*/
public void setName(String name) {
+ String oldName = this.name;
this.name = name;
+ if (!equal(oldName, name)) {
+ firePropertyChange(PROPERTY_NAME, oldName, name);
+ }
}
/**
- * Returns the local path of the project.
+ * Returns the description of the project.
*
- * @return The local path of the project
+ * @return The description of the project
*/
- public String getLocalPath() {
- return localPath;
+ public String getDescription() {
+ return description;
}
/**
- * Sets the local path of the project.
+ * Sets the description of the project
*
- * @param localPath
- * The local path of the project
+ * @param description
+ * The description of the project
*/
- public void setLocalPath(String localPath) {
- this.localPath = localPath;
+ public void setDescription(String description) {
+ String oldDescription = this.description;
+ this.description = description;
+ if (!equal(oldDescription, description)) {
+ firePropertyChange(PROPERTY_DESCRIPTION, oldDescription, description);
+ }
}
/**
* The public key of the project
*/
public void setPublicKey(String publicKey) {
+ String oldPublicKey = this.publicKey;
this.publicKey = publicKey;
+ if (!equal(oldPublicKey, publicKey)) {
+ firePropertyChange(PROPERTY_PUBLIC_KEY, oldPublicKey, publicKey);
+ }
}
/**
* The private key of the project
*/
public void setPrivateKey(String privateKey) {
+ String oldPrivateKey = this.privateKey;
this.privateKey = privateKey;
+ if (!equal(oldPrivateKey, privateKey)) {
+ firePropertyChange(PROPERTY_PRIVATE_KEY, oldPrivateKey, privateKey);
+ }
+ }
+
+ /**
+ * Returns the local path of the project.
+ *
+ * @return The local path of the project
+ */
+ public String getLocalPath() {
+ return localPath;
+ }
+
+ /**
+ * Sets the local path of the project.
+ *
+ * @param localPath
+ * The local path of the project
+ */
+ public void setLocalPath(String localPath) {
+ String oldLocalPath = this.localPath;
+ this.localPath = localPath;
+ firePropertyChange(PROPERTY_LOCAL_PATH, oldLocalPath, localPath);
}
}