Add notifications for Sones that are rescued.
[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
25 /**
26  * Manager for {@link CoreListener}s.
27  *
28  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
29  */
30 public class CoreListenerManager extends AbstractListenerManager<Core, CoreListener> {
31
32         /**
33          * Creates a new core listener manager.
34          *
35          * @param source
36          *            The Core
37          */
38         public CoreListenerManager(Core source) {
39                 super(source);
40         }
41
42         //
43         // ACTIONS
44         //
45
46         /**
47          * Notifies all listeners that the given Sone is now being rescued.
48          *
49          * @see CoreListener#rescuingSone(Sone)
50          * @param sone
51          *            The Sone that is being rescued
52          */
53         void fireRescuingSone(Sone sone) {
54                 for (CoreListener coreListener : getListeners()) {
55                         coreListener.rescuingSone(sone);
56                 }
57         }
58
59         /**
60          * Notifies all listeners that the given Sone was rescued.
61          *
62          * @see CoreListener#rescuedSone(Sone)
63          * @param sone
64          *            The Sone that was rescued
65          */
66         void fireRescuedSone(Sone sone) {
67                 for (CoreListener coreListener : getListeners()) {
68                         coreListener.rescuedSone(sone);
69                 }
70         }
71
72         /**
73          * Notifies all listeners that a new Sone has been discovered.
74          *
75          * @see CoreListener#newSoneFound(Sone)
76          * @param sone
77          *            The discovered sone
78          */
79         void fireNewSoneFound(Sone sone) {
80                 for (CoreListener coreListener : getListeners()) {
81                         coreListener.newSoneFound(sone);
82                 }
83         }
84
85         /**
86          * Notifies all listeners that a new post has been found.
87          *
88          * @see CoreListener#newPostFound(Post)
89          * @param post
90          *            The new post
91          */
92         void fireNewPostFound(Post post) {
93                 for (CoreListener coreListener : getListeners()) {
94                         coreListener.newPostFound(post);
95                 }
96         }
97
98         /**
99          * Notifies all listeners that a new reply has been found.
100          *
101          * @see CoreListener#newReplyFound(Reply)
102          * @param reply
103          *            The new reply
104          */
105         void fireNewReplyFound(Reply reply) {
106                 for (CoreListener coreListener : getListeners()) {
107                         coreListener.newReplyFound(reply);
108                 }
109         }
110
111         /**
112          * Notifies all listeners that the given Sone is now marked as known.
113          *
114          * @see CoreListener#markSoneKnown(Sone)
115          * @param sone
116          *            The known Sone
117          */
118         void fireMarkSoneKnown(Sone sone) {
119                 for (CoreListener coreListener : getListeners()) {
120                         coreListener.markSoneKnown(sone);
121                 }
122         }
123
124         /**
125          * Notifies all listeners that the given post is now marked as known.
126          *
127          * @param post
128          *            The known post
129          */
130         void fireMarkPostKnown(Post post) {
131                 for (CoreListener coreListener : getListeners()) {
132                         coreListener.markPostKnown(post);
133                 }
134         }
135
136         /**
137          * Notifies all listeners that the given reply is now marked as known.
138          *
139          * @param reply
140          *            The known reply
141          */
142         void fireMarkReplyKnown(Reply reply) {
143                 for (CoreListener coreListener : getListeners()) {
144                         coreListener.markReplyKnown(reply);
145                 }
146         }
147
148 }