Remove remnants of the old Rescue Mode.
[Sone.git] / src / main / java / net / pterodactylus / sone / core / CoreListenerManager.java
1 /*
2  * Sone - CoreListenerManager.java - Copyright © 2010 David Roden
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17
18 package net.pterodactylus.sone.core;
19
20 import net.pterodactylus.sone.data.Post;
21 import net.pterodactylus.sone.data.Reply;
22 import net.pterodactylus.sone.data.Sone;
23 import net.pterodactylus.util.event.AbstractListenerManager;
24 import net.pterodactylus.util.version.Version;
25
26 /**
27  * Manager for {@link CoreListener}s.
28  *
29  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
30  */
31 public class CoreListenerManager extends AbstractListenerManager<Core, CoreListener> {
32
33         /**
34          * Creates a new core listener manager.
35          *
36          * @param source
37          *            The Core
38          */
39         public CoreListenerManager(Core source) {
40                 super(source);
41         }
42
43         //
44         // ACTIONS
45         //
46
47         /**
48          * Notifies all listeners that a new Sone has been discovered.
49          *
50          * @see CoreListener#newSoneFound(Sone)
51          * @param sone
52          *            The discovered sone
53          */
54         void fireNewSoneFound(Sone sone) {
55                 for (CoreListener coreListener : getListeners()) {
56                         coreListener.newSoneFound(sone);
57                 }
58         }
59
60         /**
61          * Notifies all listeners that a new post has been found.
62          *
63          * @see CoreListener#newPostFound(Post)
64          * @param post
65          *            The new post
66          */
67         void fireNewPostFound(Post post) {
68                 for (CoreListener coreListener : getListeners()) {
69                         coreListener.newPostFound(post);
70                 }
71         }
72
73         /**
74          * Notifies all listeners that a new reply has been found.
75          *
76          * @see CoreListener#newReplyFound(Reply)
77          * @param reply
78          *            The new reply
79          */
80         void fireNewReplyFound(Reply reply) {
81                 for (CoreListener coreListener : getListeners()) {
82                         coreListener.newReplyFound(reply);
83                 }
84         }
85
86         /**
87          * Notifies all listeners that the given Sone is now marked as known.
88          *
89          * @see CoreListener#markSoneKnown(Sone)
90          * @param sone
91          *            The known Sone
92          */
93         void fireMarkSoneKnown(Sone sone) {
94                 for (CoreListener coreListener : getListeners()) {
95                         coreListener.markSoneKnown(sone);
96                 }
97         }
98
99         /**
100          * Notifies all listeners that the given post is now marked as known.
101          *
102          * @param post
103          *            The known post
104          */
105         void fireMarkPostKnown(Post post) {
106                 for (CoreListener coreListener : getListeners()) {
107                         coreListener.markPostKnown(post);
108                 }
109         }
110
111         /**
112          * Notifies all listeners that the given reply is now marked as known.
113          *
114          * @param reply
115          *            The known reply
116          */
117         void fireMarkReplyKnown(Reply reply) {
118                 for (CoreListener coreListener : getListeners()) {
119                         coreListener.markReplyKnown(reply);
120                 }
121         }
122
123         /**
124          * Notifies all listener that the given Sone was removed.
125          *
126          * @see CoreListener#soneRemoved(Sone)
127          * @param sone
128          *            The removed Sone
129          */
130         void fireSoneRemoved(Sone sone) {
131                 for (CoreListener coreListener : getListeners()) {
132                         coreListener.soneRemoved(sone);
133                 }
134         }
135
136         /**
137          * Notifies all listener that the given post was removed.
138          *
139          * @see CoreListener#postRemoved(Post)
140          * @param post
141          *            The removed post
142          */
143         void firePostRemoved(Post post) {
144                 for (CoreListener coreListener : getListeners()) {
145                         coreListener.postRemoved(post);
146                 }
147         }
148
149         /**
150          * Notifies all listener that the given reply was removed.
151          *
152          * @see CoreListener#replyRemoved(Reply)
153          * @param reply
154          *            The removed reply
155          */
156         void fireReplyRemoved(Reply reply) {
157                 for (CoreListener coreListener : getListeners()) {
158                         coreListener.replyRemoved(reply);
159                 }
160         }
161
162         /**
163          * Notifies all listeners that the given Sone was locked.
164          *
165          * @see CoreListener#soneLocked(Sone)
166          * @param sone
167          *            The Sone that was locked
168          */
169         void fireSoneLocked(Sone sone) {
170                 for (CoreListener coreListener : getListeners()) {
171                         coreListener.soneLocked(sone);
172                 }
173         }
174
175         /**
176          * Notifies all listeners that the given Sone was unlocked.
177          *
178          * @see CoreListener#soneUnlocked(Sone)
179          * @param sone
180          *            The Sone that was unlocked
181          */
182         void fireSoneUnlocked(Sone sone) {
183                 for (CoreListener coreListener : getListeners()) {
184                         coreListener.soneUnlocked(sone);
185                 }
186         }
187
188         /**
189          * Notifies all listeners that the insert of the given Sone has started.
190          *
191          * @see SoneInsertListener#insertStarted(Sone)
192          * @param sone
193          *            The Sone being inserted
194          */
195         void fireSoneInserting(Sone sone) {
196                 for (CoreListener coreListener : getListeners()) {
197                         coreListener.soneInserting(sone);
198                 }
199         }
200
201         /**
202          * Notifies all listeners that the insert of the given Sone has finished
203          * successfully.
204          *
205          * @see SoneInsertListener#insertFinished(Sone, long)
206          * @param sone
207          *            The Sone that was inserted
208          * @param insertDuration
209          *            The insert duration (in milliseconds)
210          */
211         void fireSoneInserted(Sone sone, long insertDuration) {
212                 for (CoreListener coreListener : getListeners()) {
213                         coreListener.soneInserted(sone, insertDuration);
214                 }
215         }
216
217         /**
218          * Notifies all listeners that the insert of the given Sone was aborted.
219          *
220          * @see SoneInsertListener#insertStarted(Sone)
221          * @param sone
222          *            The Sone being inserted
223          * @param cause
224          *            The cause for the abortion (may be {@code null}
225          */
226         void fireSoneInsertAborted(Sone sone, Throwable cause) {
227                 for (CoreListener coreListener : getListeners()) {
228                         coreListener.soneInsertAborted(sone, cause);
229                 }
230         }
231
232         /**
233          * Notifies all listeners that a new version was found.
234          *
235          * @see CoreListener#updateFound(Version, long, long)
236          * @param version
237          *            The new version
238          * @param releaseTime
239          *            The release time of the new version
240          * @param latestEdition
241          *            The latest edition of the Sone homepage
242          */
243         void fireUpdateFound(Version version, long releaseTime, long latestEdition) {
244                 for (CoreListener coreListener : getListeners()) {
245                         coreListener.updateFound(version, releaseTime, latestEdition);
246                 }
247         }
248
249 }