extract abstract bean superclass
[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 import net.pterodactylus.util.beans.Comparer;
26
27 /**
28  * Container for project information. A Project is capable of notifying
29  * {@link PropertyChangeListener}s if any of the contained properties change.
30  * 
31  * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
32  * @version $Id$
33  */
34 public class Project extends 
35 AbstractBean {
36
37         /** Name of the “name” property. */
38         public static final String PROPERTY_NAME = "name";
39
40         /** Name of the “description” property. */
41         public static final String PROPERTY_DESCRIPTION = "description";
42
43         /** Name of the “public key” property. */
44         public static final String PROPERTY_PUBLIC_KEY = "publicKey";
45
46         /** Name of the “private key” property. */
47         public static final String PROPERTY_PRIVATE_KEY = "privateKey";
48
49         /** Name of the “local path” property. */
50         public static final String PROPERTY_LOCAL_PATH = "localPath";
51
52         /** The name of the project. */
53         private String name;
54
55         /** The description of the project. */
56         private String description;
57
58         /** The public key. */
59         private String publicKey;
60
61         /** The private key. */
62         private String privateKey;
63
64         /** The local path of the project. */
65         private String localPath;
66
67         //
68         // EVENT MANAGEMENT
69         //
70
71         /**
72          * Returns the name of the project.
73          * 
74          * @return The name of the project
75          */
76         public String getName() {
77                 return name;
78         }
79
80         /**
81          * Sets the name of the project.
82          * 
83          * @param name
84          *            The name of the project
85          */
86         public void setName(String name) {
87                 String oldName = this.name;
88                 this.name = name;
89                 if (!Comparer.equal(oldName, name)) {
90                         firePropertyChange(PROPERTY_NAME, oldName, name);
91                 }
92         }
93
94         /**
95          * Returns the description of the project.
96          * 
97          * @return The description of the project
98          */
99         public String getDescription() {
100                 return description;
101         }
102
103         /**
104          * Sets the description of the project
105          * 
106          * @param description
107          *            The description of the project
108          */
109         public void setDescription(String description) {
110                 String oldDescription = this.description;
111                 this.description = description;
112                 if (!Comparer.equal(oldDescription, description)) {
113                         firePropertyChange(PROPERTY_DESCRIPTION, oldDescription, description);
114                 }
115         }
116
117         /**
118          * Returns the public key of the project.
119          * 
120          * @return The public key of the project
121          */
122         public String getPublicKey() {
123                 return publicKey;
124         }
125
126         /**
127          * Sets the public key of the project.
128          * 
129          * @param publicKey
130          *            The public key of the project
131          */
132         public void setPublicKey(String publicKey) {
133                 String oldPublicKey = this.publicKey;
134                 this.publicKey = publicKey;
135                 if (!Comparer.equal(oldPublicKey, publicKey)) {
136                         firePropertyChange(PROPERTY_PUBLIC_KEY, oldPublicKey, publicKey);
137                 }
138         }
139
140         /**
141          * Returns the private key of the project.
142          * 
143          * @return The private key of the project
144          */
145         public String getPrivateKey() {
146                 return privateKey;
147         }
148
149         /**
150          * Sets the private key of the project.
151          * 
152          * @param privateKey
153          *            The private key of the project
154          */
155         public void setPrivateKey(String privateKey) {
156                 String oldPrivateKey = this.privateKey;
157                 this.privateKey = privateKey;
158                 if (!Comparer.equal(oldPrivateKey, privateKey)) {
159                         firePropertyChange(PROPERTY_PRIVATE_KEY, oldPrivateKey, privateKey);
160                 }
161         }
162
163         /**
164          * Returns the local path of the project.
165          * 
166          * @return The local path of the project
167          */
168         public String getLocalPath() {
169                 return localPath;
170         }
171
172         /**
173          * Sets the local path of the project.
174          * 
175          * @param localPath
176          *            The local path of the project
177          */
178         public void setLocalPath(String localPath) {
179                 String oldLocalPath = this.localPath;
180                 this.localPath = localPath;
181                 firePropertyChange(PROPERTY_LOCAL_PATH, oldLocalPath, localPath);
182         }
183
184 }