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 a new Sone has been discovered.
50 * @see CoreListener#newSoneFound(Sone)
54 void fireNewSoneFound(Sone sone) {
55 for (CoreListener coreListener : getListeners()) {
56 coreListener.newSoneFound(sone);
61 * Notifies all listeners that a new post has been found.
63 * @see CoreListener#newPostFound(Post)
67 void fireNewPostFound(Post post) {
68 for (CoreListener coreListener : getListeners()) {
69 coreListener.newPostFound(post);
74 * Notifies all listeners that a new reply has been found.
76 * @see CoreListener#newReplyFound(Reply)
80 void fireNewReplyFound(Reply reply) {
81 for (CoreListener coreListener : getListeners()) {
82 coreListener.newReplyFound(reply);
87 * Notifies all listeners that the given Sone is now marked as known.
89 * @see CoreListener#markSoneKnown(Sone)
93 void fireMarkSoneKnown(Sone sone) {
94 for (CoreListener coreListener : getListeners()) {
95 coreListener.markSoneKnown(sone);
100 * Notifies all listeners that the given post is now marked as known.
105 void fireMarkPostKnown(Post post) {
106 for (CoreListener coreListener : getListeners()) {
107 coreListener.markPostKnown(post);
112 * Notifies all listeners that the given reply is now marked as known.
117 void fireMarkReplyKnown(Reply reply) {
118 for (CoreListener coreListener : getListeners()) {
119 coreListener.markReplyKnown(reply);
124 * Notifies all listener that the given Sone was removed.
126 * @see CoreListener#soneRemoved(Sone)
130 void fireSoneRemoved(Sone sone) {
131 for (CoreListener coreListener : getListeners()) {
132 coreListener.soneRemoved(sone);
137 * Notifies all listener that the given post was removed.
139 * @see CoreListener#postRemoved(Post)
143 void firePostRemoved(Post post) {
144 for (CoreListener coreListener : getListeners()) {
145 coreListener.postRemoved(post);
150 * Notifies all listener that the given reply was removed.
152 * @see CoreListener#replyRemoved(Reply)
156 void fireReplyRemoved(Reply reply) {
157 for (CoreListener coreListener : getListeners()) {
158 coreListener.replyRemoved(reply);
163 * Notifies all listeners that the given Sone was locked.
165 * @see CoreListener#soneLocked(Sone)
167 * The Sone that was locked
169 void fireSoneLocked(Sone sone) {
170 for (CoreListener coreListener : getListeners()) {
171 coreListener.soneLocked(sone);
176 * Notifies all listeners that the given Sone was unlocked.
178 * @see CoreListener#soneUnlocked(Sone)
180 * The Sone that was unlocked
182 void fireSoneUnlocked(Sone sone) {
183 for (CoreListener coreListener : getListeners()) {
184 coreListener.soneUnlocked(sone);
189 * Notifies all listeners that the insert of the given Sone has started.
191 * @see SoneInsertListener#insertStarted(Sone)
193 * The Sone being inserted
195 void fireSoneInserting(Sone sone) {
196 for (CoreListener coreListener : getListeners()) {
197 coreListener.soneInserting(sone);
202 * Notifies all listeners that the insert of the given Sone has finished
205 * @see SoneInsertListener#insertFinished(Sone, long)
207 * The Sone that was inserted
208 * @param insertDuration
209 * The insert duration (in milliseconds)
211 void fireSoneInserted(Sone sone, long insertDuration) {
212 for (CoreListener coreListener : getListeners()) {
213 coreListener.soneInserted(sone, insertDuration);
218 * Notifies all listeners that the insert of the given Sone was aborted.
220 * @see SoneInsertListener#insertStarted(Sone)
222 * The Sone being inserted
224 * The cause for the abortion (may be {@code null}
226 void fireSoneInsertAborted(Sone sone, Throwable cause) {
227 for (CoreListener coreListener : getListeners()) {
228 coreListener.soneInsertAborted(sone, cause);
233 * Notifies all listeners that a new version was found.
235 * @see CoreListener#updateFound(Version, long, long)
239 * The release time of the new version
240 * @param latestEdition
241 * The latest edition of the Sone homepage
243 void fireUpdateFound(Version version, long releaseTime, long latestEdition) {
244 for (CoreListener coreListener : getListeners()) {
245 coreListener.updateFound(version, releaseTime, latestEdition);