2 * Sone - SoneInsertListenerManager.java - Copyright © 2011 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.Sone;
21 import net.pterodactylus.util.event.AbstractListenerManager;
24 * Manager for {@link SoneInsertListener}s.
26 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
28 public class SoneInsertListenerManager extends AbstractListenerManager<Sone, SoneInsertListener> {
31 * Creates a new Sone insert listener manager.
34 * The sone being inserted
36 public SoneInsertListenerManager(Sone sone) {
45 * Notifies all listeners that the insert of the Sone has started.
47 * @see SoneInsertListener#insertStarted(Sone)
49 void fireInsertStarted() {
50 for (SoneInsertListener soneInsertListener : getListeners()) {
51 soneInsertListener.insertStarted(getSource());
56 * Notifies all listeners that the insert of the Sone has finished
59 * @see SoneInsertListener#insertFinished(Sone, long)
60 * @param insertDuration
61 * The insert duration (in milliseconds)
63 void fireInsertFinished(long insertDuration) {
64 for (SoneInsertListener soneInsertListener : getListeners()) {
65 soneInsertListener.insertFinished(getSource(), insertDuration);
70 * Notifies all listeners that the insert of the Sone was aborted.
72 * @see SoneInsertListener#insertAborted(Sone, Throwable)
74 * The cause of the abortion (may be {@code null}
76 void fireInsertAborted(Throwable cause) {
77 for (SoneInsertListener soneInsertListener : getListeners()) {
78 soneInsertListener.insertAborted(getSource(), cause);