move compare method to AbstractBean
[jSite2.git] / src / net / pterodactylus / jsite / core / Project.java
1 /*
2  * jSite2 - Project.java -
3  * Copyright © 2008 David Roden
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  */
19
20 package net.pterodactylus.jsite.core;
21
22 import java.beans.PropertyChangeListener;
23
24 import net.pterodactylus.util.beans.AbstractBean;
25
26 /**
27  * Container for project information. A Project is capable of notifying
28  * {@link PropertyChangeListener}s if any of the contained properties change.
29  * 
30  * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
31  * @version $Id$
32  */
33 public class Project extends 
34 AbstractBean {
35
36         /** Name of the “name” property. */
37         public static final String PROPERTY_NAME = "name";
38
39         /** Name of the “description” property. */
40         public static final String PROPERTY_DESCRIPTION = "description";
41
42         /** Name of the “public key” property. */
43         public static final String PROPERTY_PUBLIC_KEY = "publicKey";
44
45         /** Name of the “private key” property. */
46         public static final String PROPERTY_PRIVATE_KEY = "privateKey";
47
48         /** Name of the “local path” property. */
49         public static final String PROPERTY_LOCAL_PATH = "localPath";
50
51         /** The name of the project. */
52         private String name;
53
54         /** The description of the project. */
55         private String description;
56
57         /** The public key. */
58         private String publicKey;
59
60         /** The private key. */
61         private String privateKey;
62
63         /** The local path of the project. */
64         private String localPath;
65
66         //
67         // EVENT MANAGEMENT
68         //
69
70         /**
71          * Returns the name of the project.
72          * 
73          * @return The name of the project
74          */
75         public String getName() {
76                 return name;
77         }
78
79         /**
80          * Sets the name of the project.
81          * 
82          * @param name
83          *            The name of the project
84          */
85         public void setName(String name) {
86                 String oldName = this.name;
87                 this.name = name;
88                 if (!equal(oldName, name)) {
89                         firePropertyChange(PROPERTY_NAME, oldName, name);
90                 }
91         }
92
93         /**
94          * Returns the description of the project.
95          * 
96          * @return The description of the project
97          */
98         public String getDescription() {
99                 return description;
100         }
101
102         /**
103          * Sets the description of the project
104          * 
105          * @param description
106          *            The description of the project
107          */
108         public void setDescription(String description) {
109                 String oldDescription = this.description;
110                 this.description = description;
111                 if (!equal(oldDescription, description)) {
112                         firePropertyChange(PROPERTY_DESCRIPTION, oldDescription, description);
113                 }
114         }
115
116         /**
117          * Returns the public key of the project.
118          * 
119          * @return The public key of the project
120          */
121         public String getPublicKey() {
122                 return publicKey;
123         }
124
125         /**
126          * Sets the public key of the project.
127          * 
128          * @param publicKey
129          *            The public key of the project
130          */
131         public void setPublicKey(String publicKey) {
132                 String oldPublicKey = this.publicKey;
133                 this.publicKey = publicKey;
134                 if (!equal(oldPublicKey, publicKey)) {
135                         firePropertyChange(PROPERTY_PUBLIC_KEY, oldPublicKey, publicKey);
136                 }
137         }
138
139         /**
140          * Returns the private key of the project.
141          * 
142          * @return The private key of the project
143          */
144         public String getPrivateKey() {
145                 return privateKey;
146         }
147
148         /**
149          * Sets the private key of the project.
150          * 
151          * @param privateKey
152          *            The private key of the project
153          */
154         public void setPrivateKey(String privateKey) {
155                 String oldPrivateKey = this.privateKey;
156                 this.privateKey = privateKey;
157                 if (!equal(oldPrivateKey, privateKey)) {
158                         firePropertyChange(PROPERTY_PRIVATE_KEY, oldPrivateKey, privateKey);
159                 }
160         }
161
162         /**
163          * Returns the local path of the project.
164          * 
165          * @return The local path of the project
166          */
167         public String getLocalPath() {
168                 return localPath;
169         }
170
171         /**
172          * Sets the local path of the project.
173          * 
174          * @param localPath
175          *            The local path of the project
176          */
177         public void setLocalPath(String localPath) {
178                 String oldLocalPath = this.localPath;
179                 this.localPath = localPath;
180                 firePropertyChange(PROPERTY_LOCAL_PATH, oldLocalPath, localPath);
181         }
182
183 }