Add “update found” event to core listener.
[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 the given Sone is now being rescued.
49          *
50          * @see CoreListener#rescuingSone(Sone)
51          * @param sone
52          *            The Sone that is being rescued
53          */
54         void fireRescuingSone(Sone sone) {
55                 for (CoreListener coreListener : getListeners()) {
56                         coreListener.rescuingSone(sone);
57                 }
58         }
59
60         /**
61          * Notifies all listeners that the given Sone was rescued.
62          *
63          * @see CoreListener#rescuedSone(Sone)
64          * @param sone
65          *            The Sone that was rescued
66          */
67         void fireRescuedSone(Sone sone) {
68                 for (CoreListener coreListener : getListeners()) {
69                         coreListener.rescuedSone(sone);
70                 }
71         }
72
73         /**
74          * Notifies all listeners that a new Sone has been discovered.
75          *
76          * @see CoreListener#newSoneFound(Sone)
77          * @param sone
78          *            The discovered sone
79          */
80         void fireNewSoneFound(Sone sone) {
81                 for (CoreListener coreListener : getListeners()) {
82                         coreListener.newSoneFound(sone);
83                 }
84         }
85
86         /**
87          * Notifies all listeners that a new post has been found.
88          *
89          * @see CoreListener#newPostFound(Post)
90          * @param post
91          *            The new post
92          */
93         void fireNewPostFound(Post post) {
94                 for (CoreListener coreListener : getListeners()) {
95                         coreListener.newPostFound(post);
96                 }
97         }
98
99         /**
100          * Notifies all listeners that a new reply has been found.
101          *
102          * @see CoreListener#newReplyFound(Reply)
103          * @param reply
104          *            The new reply
105          */
106         void fireNewReplyFound(Reply reply) {
107                 for (CoreListener coreListener : getListeners()) {
108                         coreListener.newReplyFound(reply);
109                 }
110         }
111
112         /**
113          * Notifies all listeners that the given Sone is now marked as known.
114          *
115          * @see CoreListener#markSoneKnown(Sone)
116          * @param sone
117          *            The known Sone
118          */
119         void fireMarkSoneKnown(Sone sone) {
120                 for (CoreListener coreListener : getListeners()) {
121                         coreListener.markSoneKnown(sone);
122                 }
123         }
124
125         /**
126          * Notifies all listeners that the given post is now marked as known.
127          *
128          * @param post
129          *            The known post
130          */
131         void fireMarkPostKnown(Post post) {
132                 for (CoreListener coreListener : getListeners()) {
133                         coreListener.markPostKnown(post);
134                 }
135         }
136
137         /**
138          * Notifies all listeners that the given reply is now marked as known.
139          *
140          * @param reply
141          *            The known reply
142          */
143         void fireMarkReplyKnown(Reply reply) {
144                 for (CoreListener coreListener : getListeners()) {
145                         coreListener.markReplyKnown(reply);
146                 }
147         }
148
149         /**
150          * Notifies all listener that the given post was removed.
151          *
152          * @see CoreListener#postRemoved(Post)
153          * @param post
154          *            The removed post
155          */
156         void firePostRemoved(Post post) {
157                 for (CoreListener coreListener : getListeners()) {
158                         coreListener.postRemoved(post);
159                 }
160         }
161
162         /**
163          * Notifies all listener that the given reply was removed.
164          *
165          * @see CoreListener#replyRemoved(Reply)
166          * @param reply
167          *            The removed reply
168          */
169         void fireReplyRemoved(Reply reply) {
170                 for (CoreListener coreListener : getListeners()) {
171                         coreListener.replyRemoved(reply);
172                 }
173         }
174
175         /**
176          * Notifies all listeners that the given Sone was locked.
177          *
178          * @see CoreListener#soneLocked(Sone)
179          * @param sone
180          *            The Sone that was locked
181          */
182         void fireSoneLocked(Sone sone) {
183                 for (CoreListener coreListener : getListeners()) {
184                         coreListener.soneLocked(sone);
185                 }
186         }
187
188         /**
189          * Notifies all listeners that the given Sone was unlocked.
190          *
191          * @see CoreListener#soneUnlocked(Sone)
192          * @param sone
193          *            The Sone that was unlocked
194          */
195         void fireSoneUnlocked(Sone sone) {
196                 for (CoreListener coreListener : getListeners()) {
197                         coreListener.soneUnlocked(sone);
198                 }
199         }
200
201         /**
202          * Notifies all listeners that a new version was found.
203          *
204          * @see CoreListener#updateFound(Version, long)
205          * @param version
206          *            The new version
207          * @param releaseTime
208          *            The release time of the new version
209          */
210         void fireUpdateFound(Version version, long releaseTime) {
211                 for (CoreListener coreListener : getListeners()) {
212                         coreListener.updateFound(version, releaseTime);
213                 }
214         }
215
216 }