From: David ‘Bombe’ Roden Date: Fri, 28 Jun 2019 11:23:42 +0000 (+0200) Subject: 🎨 Replace Sone events with Kotlin versions X-Git-Tag: v81^2~204 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=b5773d0578a01a950e0ff48e1f6631667ddfa998;p=Sone.git 🎨 Replace Sone events with Kotlin versions --- diff --git a/src/main/java/net/pterodactylus/sone/core/event/MarkSoneKnownEvent.java b/src/main/java/net/pterodactylus/sone/core/event/MarkSoneKnownEvent.java deleted file mode 100644 index 5bbdf5e..0000000 --- a/src/main/java/net/pterodactylus/sone/core/event/MarkSoneKnownEvent.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Sone - MarkSoneKnownEvent.java - Copyright © 2013–2019 David Roden - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package net.pterodactylus.sone.core.event; - -import net.pterodactylus.sone.data.Sone; - -/** - * Event that signals that a {@link Sone} has been marked as - * {@link Sone#isKnown() known}. - */ -public class MarkSoneKnownEvent extends SoneEvent { - - /** - * Creates a new “Sone marked known” event. - * - * @param sone - * The Sone that was marked as known - */ - public MarkSoneKnownEvent(Sone sone) { - super(sone); - } - -} diff --git a/src/main/java/net/pterodactylus/sone/core/event/NewSoneFoundEvent.java b/src/main/java/net/pterodactylus/sone/core/event/NewSoneFoundEvent.java deleted file mode 100644 index 8fb17d2..0000000 --- a/src/main/java/net/pterodactylus/sone/core/event/NewSoneFoundEvent.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Sone - NewSoneFoundEvent.java - Copyright © 2013–2019 David Roden - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package net.pterodactylus.sone.core.event; - -import net.pterodactylus.sone.data.Sone; - -/** - * Event that signals that a new remote Sone was found. - */ -public class NewSoneFoundEvent extends SoneEvent { - - /** - * Creates a new “new Sone found” event. - * - * @param sone - * The Sone that was found - */ - public NewSoneFoundEvent(Sone sone) { - super(sone); - } - -} diff --git a/src/main/java/net/pterodactylus/sone/core/event/SoneEvent.java b/src/main/java/net/pterodactylus/sone/core/event/SoneEvent.java deleted file mode 100644 index b7497ff..0000000 --- a/src/main/java/net/pterodactylus/sone/core/event/SoneEvent.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Sone - SoneEvent.java - Copyright © 2013–2019 David Roden - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package net.pterodactylus.sone.core.event; - -import net.pterodactylus.sone.data.Sone; - -/** - * Base class for Sone events. - */ -public abstract class SoneEvent { - - /** The Sone this event is about. */ - private final Sone sone; - - /** - * Creates a new Sone event. - * - * @param sone - * The Sone this event is about - */ - protected SoneEvent(Sone sone) { - this.sone = sone; - } - - // - // ACCESSORS - // - - /** - * Returns the Sone this event is about. - * - * @return The Sone this event is about - */ - public Sone sone() { - return sone; - } - -} diff --git a/src/main/java/net/pterodactylus/sone/core/event/SoneInsertAbortedEvent.java b/src/main/java/net/pterodactylus/sone/core/event/SoneInsertAbortedEvent.java deleted file mode 100644 index a8c9bb6..0000000 --- a/src/main/java/net/pterodactylus/sone/core/event/SoneInsertAbortedEvent.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Sone - SoneInsertAbortedEvent.java - Copyright © 2013–2019 David Roden - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package net.pterodactylus.sone.core.event; - -import net.pterodactylus.sone.data.Sone; - -/** - * Event that signals that a {@link Sone} insert was aborted. - */ -public class SoneInsertAbortedEvent extends SoneEvent { - - /** The cause of the abortion. */ - private final Throwable cause; - - /** - * Creates a new “Sone was inserted” event. - * - * @param sone - * The Sone that was inserted - * @param cause - * The cause of the abortion - */ - public SoneInsertAbortedEvent(Sone sone, Throwable cause) { - super(sone); - this.cause = cause; - } - - // - // ACCESSORS - // - - /** - * Returns the cause of the abortion. - * - * @return The cause of the abortion (may be {@code null}) - */ - public Throwable cause() { - return cause; - } - -} diff --git a/src/main/java/net/pterodactylus/sone/core/event/SoneInsertedEvent.java b/src/main/java/net/pterodactylus/sone/core/event/SoneInsertedEvent.java deleted file mode 100644 index 53fa935..0000000 --- a/src/main/java/net/pterodactylus/sone/core/event/SoneInsertedEvent.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Sone - SoneInsertedEvent.java - Copyright © 2013–2019 David Roden - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package net.pterodactylus.sone.core.event; - -import net.pterodactylus.sone.data.Sone; - -/** - * Event that signals that a {@link Sone} was inserted. - */ -public class SoneInsertedEvent extends SoneEvent { - - private final long insertDuration; - private final String insertFingerprint; - - public SoneInsertedEvent(Sone sone, long insertDuration, String insertFingerprint) { - super(sone); - this.insertDuration = insertDuration; - this.insertFingerprint = insertFingerprint; - } - - public long insertDuration() { - return insertDuration; - } - - public String insertFingerprint() { - return insertFingerprint; - } - -} diff --git a/src/main/java/net/pterodactylus/sone/core/event/SoneInsertingEvent.java b/src/main/java/net/pterodactylus/sone/core/event/SoneInsertingEvent.java deleted file mode 100644 index a9ef6fb..0000000 --- a/src/main/java/net/pterodactylus/sone/core/event/SoneInsertingEvent.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Sone - SoneInsertingEvent.java - Copyright © 2013–2019 David Roden - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package net.pterodactylus.sone.core.event; - -import net.pterodactylus.sone.data.Sone; - -/** - * Event that signals that a {@link Sone} is now being inserted. - */ -public class SoneInsertingEvent extends SoneEvent { - - /** - * Creates a new “Sone is being inserted” event. - * - * @param sone - * The Sone that is being inserted - */ - public SoneInsertingEvent(Sone sone) { - super(sone); - } - -} diff --git a/src/main/java/net/pterodactylus/sone/core/event/SoneLockedEvent.java b/src/main/java/net/pterodactylus/sone/core/event/SoneLockedEvent.java deleted file mode 100644 index cdc9e3a..0000000 --- a/src/main/java/net/pterodactylus/sone/core/event/SoneLockedEvent.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Sone - SoneLockedEvent.java - Copyright © 2013–2019 David Roden - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package net.pterodactylus.sone.core.event; - -import net.pterodactylus.sone.data.Sone; - -/** - * Event that signals that a {@link Sone} was locked. Only - * {@link Sone#isLocal() local Sones} can be locked. - */ -public class SoneLockedEvent extends SoneEvent { - - /** - * Creates a new “Sone locked” event. - * - * @param sone - * The Sone that was locked - */ - public SoneLockedEvent(Sone sone) { - super(sone); - } - -} diff --git a/src/main/java/net/pterodactylus/sone/core/event/SoneRemovedEvent.java b/src/main/java/net/pterodactylus/sone/core/event/SoneRemovedEvent.java deleted file mode 100644 index e46272d..0000000 --- a/src/main/java/net/pterodactylus/sone/core/event/SoneRemovedEvent.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Sone - SoneRemovedEvent.java - Copyright © 2013–2019 David Roden - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package net.pterodactylus.sone.core.event; - -import net.pterodactylus.sone.data.Sone; - -/** - * Event that signals that a {@link Sone} was removed. - */ -public class SoneRemovedEvent extends SoneEvent { - - /** - * Creates a new “Sone removed” event. - * - * @param sone - * The Sone that was removed - */ - public SoneRemovedEvent(Sone sone) { - super(sone); - } - -} diff --git a/src/main/java/net/pterodactylus/sone/core/event/SoneUnlockedEvent.java b/src/main/java/net/pterodactylus/sone/core/event/SoneUnlockedEvent.java deleted file mode 100644 index 106d32d..0000000 --- a/src/main/java/net/pterodactylus/sone/core/event/SoneUnlockedEvent.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Sone - SoneUnlockedEvent.java - Copyright © 2013–2019 David Roden - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package net.pterodactylus.sone.core.event; - -import net.pterodactylus.sone.data.Sone; - -/** - * Event that signals that a {@link Sone} was unlocked. Only - * {@link Sone#isLocal() local Sones} can be locked. - */ -public class SoneUnlockedEvent extends SoneEvent { - - /** - * Creates a new “Sone unlocked” event. - * - * @param sone - * The Sone that was unlocked - */ - public SoneUnlockedEvent(Sone sone) { - super(sone); - } - -} diff --git a/src/main/java/net/pterodactylus/sone/web/WebInterface.java b/src/main/java/net/pterodactylus/sone/web/WebInterface.java index c50f74e..397fd77 100644 --- a/src/main/java/net/pterodactylus/sone/web/WebInterface.java +++ b/src/main/java/net/pterodactylus/sone/web/WebInterface.java @@ -768,7 +768,7 @@ public class WebInterface implements SessionProvider { */ @Subscribe public void newSoneFound(NewSoneFoundEvent newSoneFoundEvent) { - newSoneNotification.add(newSoneFoundEvent.sone()); + newSoneNotification.add(newSoneFoundEvent.getSone()); if (!hasFirstStartNotification()) { notificationManager.addNotification(newSoneNotification); } @@ -834,7 +834,7 @@ public class WebInterface implements SessionProvider { */ @Subscribe public void markSoneKnown(MarkSoneKnownEvent markSoneKnownEvent) { - newSoneNotification.remove(markSoneKnownEvent.sone()); + newSoneNotification.remove(markSoneKnownEvent.getSone()); } @Subscribe @@ -849,7 +849,7 @@ public class WebInterface implements SessionProvider { @Subscribe public void soneRemoved(SoneRemovedEvent soneRemovedEvent) { - newSoneNotification.remove(soneRemovedEvent.sone()); + newSoneNotification.remove(soneRemovedEvent.getSone()); } @Subscribe @@ -886,7 +886,7 @@ public class WebInterface implements SessionProvider { */ @Subscribe public void soneLocked(SoneLockedEvent soneLockedEvent) { - final Sone sone = soneLockedEvent.sone(); + final Sone sone = soneLockedEvent.getSone(); ScheduledFuture tickerObject = ticker.schedule(new Runnable() { @Override @@ -907,8 +907,8 @@ public class WebInterface implements SessionProvider { */ @Subscribe public void soneUnlocked(SoneUnlockedEvent soneUnlockedEvent) { - lockedSonesNotification.remove(soneUnlockedEvent.sone()); - lockedSonesTickerObjects.remove(soneUnlockedEvent.sone()).cancel(false); + lockedSonesNotification.remove(soneUnlockedEvent.getSone()); + lockedSonesTickerObjects.remove(soneUnlockedEvent.getSone()).cancel(false); } /** @@ -919,9 +919,9 @@ public class WebInterface implements SessionProvider { */ @Subscribe public void soneInserting(SoneInsertingEvent soneInsertingEvent) { - TemplateNotification soneInsertNotification = getSoneInsertNotification(soneInsertingEvent.sone()); + TemplateNotification soneInsertNotification = getSoneInsertNotification(soneInsertingEvent.getSone()); soneInsertNotification.set("soneStatus", "inserting"); - if (soneInsertingEvent.sone().getOptions().isSoneInsertNotificationEnabled()) { + if (soneInsertingEvent.getSone().getOptions().isSoneInsertNotificationEnabled()) { notificationManager.addNotification(soneInsertNotification); } } @@ -934,10 +934,10 @@ public class WebInterface implements SessionProvider { */ @Subscribe public void soneInserted(SoneInsertedEvent soneInsertedEvent) { - TemplateNotification soneInsertNotification = getSoneInsertNotification(soneInsertedEvent.sone()); + TemplateNotification soneInsertNotification = getSoneInsertNotification(soneInsertedEvent.getSone()); soneInsertNotification.set("soneStatus", "inserted"); - soneInsertNotification.set("insertDuration", soneInsertedEvent.insertDuration() / 1000); - if (soneInsertedEvent.sone().getOptions().isSoneInsertNotificationEnabled()) { + soneInsertNotification.set("insertDuration", soneInsertedEvent.getInsertDuration() / 1000); + if (soneInsertedEvent.getSone().getOptions().isSoneInsertNotificationEnabled()) { notificationManager.addNotification(soneInsertNotification); } } @@ -950,10 +950,10 @@ public class WebInterface implements SessionProvider { */ @Subscribe public void soneInsertAborted(SoneInsertAbortedEvent soneInsertAbortedEvent) { - TemplateNotification soneInsertNotification = getSoneInsertNotification(soneInsertAbortedEvent.sone()); + TemplateNotification soneInsertNotification = getSoneInsertNotification(soneInsertAbortedEvent.getSone()); soneInsertNotification.set("soneStatus", "insert-aborted"); - soneInsertNotification.set("insert-error", soneInsertAbortedEvent.cause()); - if (soneInsertAbortedEvent.sone().getOptions().isSoneInsertNotificationEnabled()) { + soneInsertNotification.set("insert-error", soneInsertAbortedEvent.getCause()); + if (soneInsertAbortedEvent.getSone().getOptions().isSoneInsertNotificationEnabled()) { notificationManager.addNotification(soneInsertNotification); } } diff --git a/src/main/kotlin/net/pterodactylus/sone/core/event/MarkSoneKnownEvent.kt b/src/main/kotlin/net/pterodactylus/sone/core/event/MarkSoneKnownEvent.kt new file mode 100644 index 0000000..868eb8f --- /dev/null +++ b/src/main/kotlin/net/pterodactylus/sone/core/event/MarkSoneKnownEvent.kt @@ -0,0 +1,26 @@ +/* + * Sone - MarkSoneKnownEvent.kt - Copyright © 2013–2019 David Roden + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.pterodactylus.sone.core.event + +import net.pterodactylus.sone.data.* + +/** + * Event that signals that a [Sone] has been marked as + * [known][Sone.isKnown]. + */ +class MarkSoneKnownEvent(sone: Sone) : SoneEvent(sone) diff --git a/src/main/kotlin/net/pterodactylus/sone/core/event/NewSoneFoundEvent.kt b/src/main/kotlin/net/pterodactylus/sone/core/event/NewSoneFoundEvent.kt new file mode 100644 index 0000000..2defcb4 --- /dev/null +++ b/src/main/kotlin/net/pterodactylus/sone/core/event/NewSoneFoundEvent.kt @@ -0,0 +1,25 @@ +/* + * Sone - NewSoneFoundEvent.kt - Copyright © 2013–2019 David Roden + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.pterodactylus.sone.core.event + +import net.pterodactylus.sone.data.* + +/** + * Event that signals that a new remote Sone was found. + */ +class NewSoneFoundEvent(sone: Sone) : SoneEvent(sone) diff --git a/src/main/kotlin/net/pterodactylus/sone/core/event/SoneEvent.kt b/src/main/kotlin/net/pterodactylus/sone/core/event/SoneEvent.kt new file mode 100644 index 0000000..6692be4 --- /dev/null +++ b/src/main/kotlin/net/pterodactylus/sone/core/event/SoneEvent.kt @@ -0,0 +1,25 @@ +/* + * Sone - SoneEvent.kt - Copyright © 2013–2019 David Roden + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.pterodactylus.sone.core.event + +import net.pterodactylus.sone.data.* + +/** + * Base class for Sone events. + */ +abstract class SoneEvent(val sone: Sone) diff --git a/src/main/kotlin/net/pterodactylus/sone/core/event/SoneInsertAbortedEvent.kt b/src/main/kotlin/net/pterodactylus/sone/core/event/SoneInsertAbortedEvent.kt new file mode 100644 index 0000000..0f3e9ec --- /dev/null +++ b/src/main/kotlin/net/pterodactylus/sone/core/event/SoneInsertAbortedEvent.kt @@ -0,0 +1,25 @@ +/* + * Sone - SoneInsertAbortedEvent.kt - Copyright © 2013–2019 David Roden + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.pterodactylus.sone.core.event + +import net.pterodactylus.sone.data.* + +/** + * Event that signals that a [Sone] insert was aborted. + */ +class SoneInsertAbortedEvent(sone: Sone, val cause: Throwable) : SoneEvent(sone) diff --git a/src/main/kotlin/net/pterodactylus/sone/core/event/SoneInsertedEvent.kt b/src/main/kotlin/net/pterodactylus/sone/core/event/SoneInsertedEvent.kt new file mode 100644 index 0000000..e3a58de --- /dev/null +++ b/src/main/kotlin/net/pterodactylus/sone/core/event/SoneInsertedEvent.kt @@ -0,0 +1,25 @@ +/* + * Sone - SoneInsertedEvent.kt - Copyright © 2013–2019 David Roden + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.pterodactylus.sone.core.event + +import net.pterodactylus.sone.data.* + +/** + * Event that signals that a [Sone] was inserted. + */ +class SoneInsertedEvent(sone: Sone, val insertDuration: Long, val insertFingerprint: String) : SoneEvent(sone) diff --git a/src/main/kotlin/net/pterodactylus/sone/core/event/SoneInsertingEvent.kt b/src/main/kotlin/net/pterodactylus/sone/core/event/SoneInsertingEvent.kt new file mode 100644 index 0000000..b21b6d7 --- /dev/null +++ b/src/main/kotlin/net/pterodactylus/sone/core/event/SoneInsertingEvent.kt @@ -0,0 +1,25 @@ +/* + * Sone - SoneInsertingEvent.kt - Copyright © 2013–2019 David Roden + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.pterodactylus.sone.core.event + +import net.pterodactylus.sone.data.* + +/** + * Event that signals that a [Sone] is now being inserted. + */ +class SoneInsertingEvent(sone: Sone) : SoneEvent(sone) diff --git a/src/main/kotlin/net/pterodactylus/sone/core/event/SoneLockedEvent.kt b/src/main/kotlin/net/pterodactylus/sone/core/event/SoneLockedEvent.kt new file mode 100644 index 0000000..6f981f3 --- /dev/null +++ b/src/main/kotlin/net/pterodactylus/sone/core/event/SoneLockedEvent.kt @@ -0,0 +1,26 @@ +/* + * Sone - SoneLockedEvent.kt - Copyright © 2013–2019 David Roden + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.pterodactylus.sone.core.event + +import net.pterodactylus.sone.data.* + +/** + * Event that signals that a [Sone] was locked. Only + * [local Sones][Sone.isLocal] can be locked. + */ +class SoneLockedEvent(sone: Sone) : SoneEvent(sone) diff --git a/src/main/kotlin/net/pterodactylus/sone/core/event/SoneRemovedEvent.kt b/src/main/kotlin/net/pterodactylus/sone/core/event/SoneRemovedEvent.kt new file mode 100644 index 0000000..d08bea7 --- /dev/null +++ b/src/main/kotlin/net/pterodactylus/sone/core/event/SoneRemovedEvent.kt @@ -0,0 +1,25 @@ +/* + * Sone - SoneRemovedEvent.kt - Copyright © 2013–2019 David Roden + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.pterodactylus.sone.core.event + +import net.pterodactylus.sone.data.* + +/** + * Event that signals that a [Sone] was removed. + */ +class SoneRemovedEvent(sone: Sone) : SoneEvent(sone) diff --git a/src/main/kotlin/net/pterodactylus/sone/core/event/SoneUnlockedEvent.kt b/src/main/kotlin/net/pterodactylus/sone/core/event/SoneUnlockedEvent.kt new file mode 100644 index 0000000..58a3d21 --- /dev/null +++ b/src/main/kotlin/net/pterodactylus/sone/core/event/SoneUnlockedEvent.kt @@ -0,0 +1,26 @@ +/* + * Sone - SoneUnlockedEvent.kt - Copyright © 2013–2019 David Roden + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.pterodactylus.sone.core.event + +import net.pterodactylus.sone.data.* + +/** + * Event that signals that a [Sone] was unlocked. Only + * [local Sones][Sone.isLocal] can be locked. + */ +class SoneUnlockedEvent(sone: Sone) : SoneEvent(sone) diff --git a/src/test/java/net/pterodactylus/sone/core/CoreTest.java b/src/test/java/net/pterodactylus/sone/core/CoreTest.java index 66ef743..903cba0 100644 --- a/src/test/java/net/pterodactylus/sone/core/CoreTest.java +++ b/src/test/java/net/pterodactylus/sone/core/CoreTest.java @@ -144,8 +144,8 @@ public class CoreTest { mismatchDescription.appendText("is not SoneRemovedEvent"); return false; } - if (((SoneRemovedEvent) item).sone() != sone) { - mismatchDescription.appendText("sone is ").appendValue(((SoneRemovedEvent) item).sone()); + if (((SoneRemovedEvent) item).getSone() != sone) { + mismatchDescription.appendText("sone is ").appendValue(((SoneRemovedEvent) item).getSone()); return false; } return true; diff --git a/src/test/java/net/pterodactylus/sone/core/SoneInserterTest.java b/src/test/java/net/pterodactylus/sone/core/SoneInserterTest.java index 31d7b6b..f990500 100644 --- a/src/test/java/net/pterodactylus/sone/core/SoneInserterTest.java +++ b/src/test/java/net/pterodactylus/sone/core/SoneInserterTest.java @@ -130,9 +130,9 @@ public class SoneInserterTest { verify(freenetInterface).insertDirectory(eq(insertUri), any(HashMap.class), eq("index.html")); verify(eventBus, times(2)).post(soneEvents.capture()); assertThat(soneEvents.getAllValues().get(0), instanceOf(SoneInsertingEvent.class)); - assertThat(soneEvents.getAllValues().get(0).sone(), is(sone)); + assertThat(soneEvents.getAllValues().get(0).getSone(), is(sone)); assertThat(soneEvents.getAllValues().get(1), instanceOf(SoneInsertedEvent.class)); - assertThat(soneEvents.getAllValues().get(1).sone(), is(sone)); + assertThat(soneEvents.getAllValues().get(1).getSone(), is(sone)); } @Test @@ -156,9 +156,9 @@ public class SoneInserterTest { verify(freenetInterface).insertDirectory(eq(insertUri), any(HashMap.class), eq("index.html")); verify(eventBus, times(2)).post(soneEvents.capture()); assertThat(soneEvents.getAllValues().get(0), instanceOf(SoneInsertingEvent.class)); - assertThat(soneEvents.getAllValues().get(0).sone(), is(sone)); + assertThat(soneEvents.getAllValues().get(0).getSone(), is(sone)); assertThat(soneEvents.getAllValues().get(1), instanceOf(SoneInsertedEvent.class)); - assertThat(soneEvents.getAllValues().get(1).sone(), is(sone)); + assertThat(soneEvents.getAllValues().get(1).getSone(), is(sone)); verify(core, never()).touchConfiguration(); } @@ -206,9 +206,9 @@ public class SoneInserterTest { verify(freenetInterface).insertDirectory(eq(insertUri), any(HashMap.class), eq("index.html")); verify(eventBus, times(2)).post(soneEvents.capture()); assertThat(soneEvents.getAllValues().get(0), instanceOf(SoneInsertingEvent.class)); - assertThat(soneEvents.getAllValues().get(0).sone(), is(sone)); + assertThat(soneEvents.getAllValues().get(0).getSone(), is(sone)); assertThat(soneEvents.getAllValues().get(1), instanceOf(SoneInsertAbortedEvent.class)); - assertThat(soneEvents.getAllValues().get(1).sone(), is(sone)); + assertThat(soneEvents.getAllValues().get(1).getSone(), is(sone)); verify(core, never()).touchConfiguration(); }