package net.pterodactylus.jsite.project;
import java.beans.PropertyChangeListener;
+import java.util.HashMap;
+import java.util.Map;
import net.pterodactylus.util.beans.AbstractBean;
/**
* 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 extends AbstractBean {
/** 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";
+ /** Name of the “base path” property. */
+ public static final String PROPERTY_BASE_PATH = "basePath";
+
+ /** Internal ID. */
+ private String id;
/** The name of the project. */
private String name;
/** The base path of the project. */
private String basePath;
- //
- // EVENT MANAGEMENT
- //
+ /** The overrides. */
+ private final Map<String, Override> overrides = new HashMap<String, Override>();
+
+ /**
+ * Creates a new project.
+ */
+ public Project() {
+ /* do nothing. */
+ }
+
+ /**
+ * Clones the given project.
+ *
+ * @param project
+ */
+ Project(Project project) {
+ this.name = project.name;
+ this.description = project.description;
+ this.publicKey = project.publicKey;
+ this.privateKey = project.privateKey;
+ this.basePath = project.basePath;
+ }
+
+ /**
+ * Returns the internal ID.
+ *
+ * @return The internal ID
+ */
+ String getId() {
+ return id;
+ }
+
+ /**
+ * Sets the internal ID.
+ *
+ * @param id
+ * The internal ID
+ */
+ void setId(String id) {
+ this.id = id;
+ }
/**
* Returns the name of the project.
- *
+ *
* @return The name of the project
*/
public String getName() {
/**
* Sets the name of the project.
- *
+ *
* @param name
* 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);
- }
+ fireIfPropertyChanged(PROPERTY_NAME, oldName, name);
}
/**
* Returns the description of the project.
- *
+ *
* @return The description of the project
*/
public String getDescription() {
/**
* Sets the description of the project
- *
+ *
* @param description
* The description of the project
*/
public void setDescription(String description) {
String oldDescription = this.description;
this.description = description;
- if (!equal(oldDescription, description)) {
- firePropertyChange(PROPERTY_DESCRIPTION, oldDescription, description);
- }
+ fireIfPropertyChanged(PROPERTY_DESCRIPTION, oldDescription, description);
}
/**
* Returns the public key of the project.
- *
+ *
* @return The public key of the project
*/
public String getPublicKey() {
/**
* Sets the public key of the project.
- *
+ *
* @param publicKey
* The public key of the project
*/
- public void setPublicKey(String publicKey) {
+ void setPublicKey(String publicKey) {
String oldPublicKey = this.publicKey;
this.publicKey = publicKey;
- if (!equal(oldPublicKey, publicKey)) {
- firePropertyChange(PROPERTY_PUBLIC_KEY, oldPublicKey, publicKey);
- }
+ fireIfPropertyChanged(PROPERTY_PUBLIC_KEY, oldPublicKey, publicKey);
}
/**
* Returns the private key of the project.
- *
+ *
* @return The private key of the project
*/
public String getPrivateKey() {
/**
* Sets the private key of the project.
- *
+ *
* @param privateKey
* The private key of the project
*/
- public void setPrivateKey(String privateKey) {
+ void setPrivateKey(String privateKey) {
String oldPrivateKey = this.privateKey;
this.privateKey = privateKey;
- if (!equal(oldPrivateKey, privateKey)) {
- firePropertyChange(PROPERTY_PRIVATE_KEY, oldPrivateKey, privateKey);
- }
+ fireIfPropertyChanged(PROPERTY_PRIVATE_KEY, oldPrivateKey, privateKey);
}
/**
* Returns the base path of the project.
- *
+ *
* @return The base path of the project
*/
public String getBasePath() {
/**
* Sets the base path of the project.
- *
+ *
* @param basePath
* The base path of the project
*/
public void setBasePath(String basePath) {
String oldBasePath = this.basePath;
this.basePath = basePath;
- firePropertyChange(PROPERTY_LOCAL_PATH, oldBasePath, basePath);
+ fireIfPropertyChanged(PROPERTY_BASE_PATH, oldBasePath, basePath);
+ }
+
+ /**
+ * Adds an override for the given file.
+ *
+ * @param filePath
+ * The file path
+ * @param override
+ * The override for the file
+ */
+ public void addOverride(String filePath, Override override) {
+ overrides.put(filePath, override);
+ }
+
+ /**
+ * Removes the override for the given file.
+ *
+ * @param filePath
+ * The file path for which to remove the override
+ */
+ public void removeOverride(String filePath) {
+ overrides.remove(filePath);
+ }
+
+ /**
+ * Returns the list of {@link Override}s.
+ *
+ * @return All overrides
+ */
+ public Map<String, Override> getOverrides() {
+ return overrides;
}
}