2 * Sone - CoreListenerManager.java - Copyright © 2010 David Roden
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.
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.
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/>.
18 package net.pterodactylus.sone.core;
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;
27 * Manager for {@link CoreListener}s.
29 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
31 public class CoreListenerManager extends AbstractListenerManager<Core, CoreListener> {
34 * Creates a new core listener manager.
39 public CoreListenerManager(Core source) {
48 * Notifies all listeners that the given Sone is now being rescued.
50 * @see CoreListener#rescuingSone(Sone)
52 * The Sone that is being rescued
54 void fireRescuingSone(Sone sone) {
55 for (CoreListener coreListener : getListeners()) {
56 coreListener.rescuingSone(sone);
61 * Notifies all listeners that the given Sone was rescued.
63 * @see CoreListener#rescuedSone(Sone)
65 * The Sone that was rescued
67 void fireRescuedSone(Sone sone) {
68 for (CoreListener coreListener : getListeners()) {
69 coreListener.rescuedSone(sone);
74 * Notifies all listeners that a new Sone has been discovered.
76 * @see CoreListener#newSoneFound(Sone)
80 void fireNewSoneFound(Sone sone) {
81 for (CoreListener coreListener : getListeners()) {
82 coreListener.newSoneFound(sone);
87 * Notifies all listeners that a new post has been found.
89 * @see CoreListener#newPostFound(Post)
93 void fireNewPostFound(Post post) {
94 for (CoreListener coreListener : getListeners()) {
95 coreListener.newPostFound(post);
100 * Notifies all listeners that a new reply has been found.
102 * @see CoreListener#newReplyFound(Reply)
106 void fireNewReplyFound(Reply reply) {
107 for (CoreListener coreListener : getListeners()) {
108 coreListener.newReplyFound(reply);
113 * Notifies all listeners that the given Sone is now marked as known.
115 * @see CoreListener#markSoneKnown(Sone)
119 void fireMarkSoneKnown(Sone sone) {
120 for (CoreListener coreListener : getListeners()) {
121 coreListener.markSoneKnown(sone);
126 * Notifies all listeners that the given post is now marked as known.
131 void fireMarkPostKnown(Post post) {
132 for (CoreListener coreListener : getListeners()) {
133 coreListener.markPostKnown(post);
138 * Notifies all listeners that the given reply is now marked as known.
143 void fireMarkReplyKnown(Reply reply) {
144 for (CoreListener coreListener : getListeners()) {
145 coreListener.markReplyKnown(reply);
150 * Notifies all listener that the given post was removed.
152 * @see CoreListener#postRemoved(Post)
156 void firePostRemoved(Post post) {
157 for (CoreListener coreListener : getListeners()) {
158 coreListener.postRemoved(post);
163 * Notifies all listener that the given reply was removed.
165 * @see CoreListener#replyRemoved(Reply)
169 void fireReplyRemoved(Reply reply) {
170 for (CoreListener coreListener : getListeners()) {
171 coreListener.replyRemoved(reply);
176 * Notifies all listeners that the given Sone was locked.
178 * @see CoreListener#soneLocked(Sone)
180 * The Sone that was locked
182 void fireSoneLocked(Sone sone) {
183 for (CoreListener coreListener : getListeners()) {
184 coreListener.soneLocked(sone);
189 * Notifies all listeners that the given Sone was unlocked.
191 * @see CoreListener#soneUnlocked(Sone)
193 * The Sone that was unlocked
195 void fireSoneUnlocked(Sone sone) {
196 for (CoreListener coreListener : getListeners()) {
197 coreListener.soneUnlocked(sone);
202 * Notifies all listeners that a new version was found.
204 * @see CoreListener#updateFound(Version, long, long)
208 * The release time of the new version
209 * @param latestEdition
210 * The latest edition of the Sone homepage
212 void fireUpdateFound(Version version, long releaseTime, long latestEdition) {
213 for (CoreListener coreListener : getListeners()) {
214 coreListener.updateFound(version, releaseTime, latestEdition);