*/
@Subscribe
public void ownIdentityAdded(OwnIdentityAddedEvent ownIdentityAddedEvent) {
- OwnIdentity ownIdentity = ownIdentityAddedEvent.ownIdentity();
+ OwnIdentity ownIdentity = ownIdentityAddedEvent.getOwnIdentity();
logger.log(Level.FINEST, String.format("Adding OwnIdentity: %s", ownIdentity));
if (ownIdentity.hasContext("Sone")) {
addLocalSone(ownIdentity);
*/
@Subscribe
public void ownIdentityRemoved(OwnIdentityRemovedEvent ownIdentityRemovedEvent) {
- OwnIdentity ownIdentity = ownIdentityRemovedEvent.ownIdentity();
+ OwnIdentity ownIdentity = ownIdentityRemovedEvent.getOwnIdentity();
logger.log(Level.FINEST, String.format("Removing OwnIdentity: %s", ownIdentity));
trustedIdentities.removeAll(ownIdentity);
}
*/
@Subscribe
public void identityAdded(IdentityAddedEvent identityAddedEvent) {
- Identity identity = identityAddedEvent.identity();
+ Identity identity = identityAddedEvent.getIdentity();
logger.log(Level.FINEST, String.format("Adding Identity: %s", identity));
- trustedIdentities.put(identityAddedEvent.ownIdentity(), identity);
+ trustedIdentities.put(identityAddedEvent.getOwnIdentity(), identity);
addRemoteSone(identity);
}
*/
@Subscribe
public void identityUpdated(IdentityUpdatedEvent identityUpdatedEvent) {
- Identity identity = identityUpdatedEvent.identity();
+ Identity identity = identityUpdatedEvent.getIdentity();
final Sone sone = getRemoteSone(identity.getId());
if (sone.isLocal()) {
return;
*/
@Subscribe
public void identityRemoved(IdentityRemovedEvent identityRemovedEvent) {
- OwnIdentity ownIdentity = identityRemovedEvent.ownIdentity();
- Identity identity = identityRemovedEvent.identity();
+ OwnIdentity ownIdentity = identityRemovedEvent.getOwnIdentity();
+ Identity identity = identityRemovedEvent.getIdentity();
trustedIdentities.remove(ownIdentity, identity);
for (Entry<OwnIdentity, Collection<Identity>> trustedIdentity : trustedIdentities.asMap().entrySet()) {
if (trustedIdentity.getKey().equals(ownIdentity)) {
+++ /dev/null
-/*
- * Sone - IdentityAddedEvent.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 <http://www.gnu.org/licenses/>.
- */
-
-package net.pterodactylus.sone.freenet.wot.event;
-
-import net.pterodactylus.sone.freenet.wot.Identity;
-import net.pterodactylus.sone.freenet.wot.OwnIdentity;
-
-/**
- * Event that signals that an {@link Identity} was added.
- */
-public class IdentityAddedEvent extends IdentityEvent {
-
- /**
- * Creates a new “identity added” event.
- *
- * @param ownIdentity
- * The own identity that added the identity
- * @param identity
- * The identity that was added
- */
- public IdentityAddedEvent(OwnIdentity ownIdentity, Identity identity) {
- super(ownIdentity, identity);
- }
-
-}
+++ /dev/null
-/*
- * Sone - IdentityEvent.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 <http://www.gnu.org/licenses/>.
- */
-
-package net.pterodactylus.sone.freenet.wot.event;
-
-import net.pterodactylus.sone.freenet.wot.Identity;
-import net.pterodactylus.sone.freenet.wot.OwnIdentity;
-
-/**
- * Base class for {@link Identity} events.
- */
-public abstract class IdentityEvent {
-
- /** The own identity this event relates to. */
- private final OwnIdentity ownIdentity;
-
- /** The identity this event is about. */
- private final Identity identity;
-
- /**
- * Creates a new identity-based event.
- *
- * @param ownIdentity
- * The own identity that relates to the identity
- * @param identity
- * The identity this event is about
- */
- protected IdentityEvent(OwnIdentity ownIdentity, Identity identity) {
- this.ownIdentity = ownIdentity;
- this.identity = identity;
- }
-
- //
- // ACCESSORS
- //
-
- /**
- * Returns the own identity this event relates to.
- *
- * @return The own identity this event relates to
- */
- public OwnIdentity ownIdentity() {
- return ownIdentity;
- }
-
- /**
- * Returns the identity this event is about.
- *
- * @return The identity this event is about
- */
- public Identity identity() {
- return identity;
- }
-
- @Override
- public int hashCode() {
- return ownIdentity().hashCode() ^ identity().hashCode();
- }
-
- @Override
- public boolean equals(Object object) {
- if ((object == null) || !object.getClass().equals(getClass())) {
- return false;
- }
- IdentityEvent identityEvent = (IdentityEvent) object;
- return ownIdentity().equals(identityEvent.ownIdentity()) && identity().equals(identityEvent.identity());
- }
-
-}
+++ /dev/null
-/*
- * Sone - IdentityRemovedEvent.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 <http://www.gnu.org/licenses/>.
- */
-
-package net.pterodactylus.sone.freenet.wot.event;
-
-import net.pterodactylus.sone.freenet.wot.Identity;
-import net.pterodactylus.sone.freenet.wot.OwnIdentity;
-
-/**
- * Event that signals that an {@link Identity} was removed.
- */
-public class IdentityRemovedEvent extends IdentityEvent {
-
- /**
- * Creates a new “identity removed” event.
- *
- * @param ownIdentity
- * The own identity that removed the identity
- * @param identity
- * The identity that was removed
- */
- public IdentityRemovedEvent(OwnIdentity ownIdentity, Identity identity) {
- super(ownIdentity, identity);
- }
-
-}
+++ /dev/null
-/*
- * Sone - IdentityUpdatedEvent.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 <http://www.gnu.org/licenses/>.
- */
-
-package net.pterodactylus.sone.freenet.wot.event;
-
-import net.pterodactylus.sone.freenet.wot.Identity;
-import net.pterodactylus.sone.freenet.wot.OwnIdentity;
-
-/**
- * Event that signals that an {@link Identity} was updated.
- */
-public class IdentityUpdatedEvent extends IdentityEvent {
-
- /**
- * Creates a new “identity updated” event.
- *
- * @param ownIdentity
- * The own identity that tracks the identity
- * @param identity
- * The identity that was updated
- */
- public IdentityUpdatedEvent(OwnIdentity ownIdentity, Identity identity) {
- super(ownIdentity, identity);
- }
-
-}
+++ /dev/null
-/*
- * Sone - OwnIdentityAddedEvent.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 <http://www.gnu.org/licenses/>.
- */
-
-package net.pterodactylus.sone.freenet.wot.event;
-
-import net.pterodactylus.sone.freenet.wot.OwnIdentity;
-
-/**
- * Event that signals that an {@link OwnIdentity} was added.
- */
-public class OwnIdentityAddedEvent extends OwnIdentityEvent {
-
- /**
- * Creates new “own identity added” event.
- *
- * @param ownIdentity
- * The own identity that was added
- */
- public OwnIdentityAddedEvent(OwnIdentity ownIdentity) {
- super(ownIdentity);
- }
-
-}
+++ /dev/null
-/*
- * Sone - OwnIdentityEvent.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 <http://www.gnu.org/licenses/>.
- */
-
-package net.pterodactylus.sone.freenet.wot.event;
-
-import net.pterodactylus.sone.freenet.wot.OwnIdentity;
-
-/**
- * Base class for {@link OwnIdentity} events.
- */
-public abstract class OwnIdentityEvent {
-
- /** The own identity this event is about. */
- private final OwnIdentity ownIdentity;
-
- /**
- * Creates a new own identity-based event.
- *
- * @param ownIdentity
- * The own identity this event is about
- */
- protected OwnIdentityEvent(OwnIdentity ownIdentity) {
- this.ownIdentity = ownIdentity;
- }
-
- //
- // ACCESSORS
- //
-
- /**
- * Returns the own identity this event is about.
- *
- * @return The own identity this event is about
- */
- public OwnIdentity ownIdentity() {
- return ownIdentity;
- }
-
- @Override
- public int hashCode() {
- return ownIdentity().hashCode();
- }
-
- @Override
- public boolean equals(Object object) {
- if ((object == null) || !object.getClass().equals(getClass())) {
- return false;
- }
- OwnIdentityEvent ownIdentityEvent = (OwnIdentityEvent) object;
- return ownIdentity().equals(ownIdentityEvent.ownIdentity());
- }
-
-}
+++ /dev/null
-/*
- * Sone - OwnIdentityRemovedEvent.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 <http://www.gnu.org/licenses/>.
- */
-
-package net.pterodactylus.sone.freenet.wot.event;
-
-import net.pterodactylus.sone.freenet.wot.OwnIdentity;
-
-/**
- * Event that signals that an {@link OwnIdentity} was removed.
- */
-public class OwnIdentityRemovedEvent extends OwnIdentityEvent {
-
- /**
- * Creates a new “own identity removed” event.
- *
- * @param ownIdentity
- * The own identity that was removed
- */
- public OwnIdentityRemovedEvent(OwnIdentity ownIdentity) {
- super(ownIdentity);
- }
-
-}
--- /dev/null
+/*
+ * Sone - IdentityAddedEvent.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 <http://www.gnu.org/licenses/>.
+ */
+
+package net.pterodactylus.sone.freenet.wot.event
+
+import net.pterodactylus.sone.freenet.wot.*
+
+/**
+ * Event that signals that an [Identity] was added.
+ */
+data class IdentityAddedEvent(val ownIdentity: OwnIdentity, val identity: Identity)
--- /dev/null
+/*
+ * Sone - IdentityRemovedEvent.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 <http://www.gnu.org/licenses/>.
+ */
+
+package net.pterodactylus.sone.freenet.wot.event
+
+import net.pterodactylus.sone.freenet.wot.Identity
+import net.pterodactylus.sone.freenet.wot.OwnIdentity
+
+/**
+ * Event that signals that an [Identity] was removed.
+ */
+data class IdentityRemovedEvent(val ownIdentity: OwnIdentity, val identity: Identity)
--- /dev/null
+/*
+ * Sone - IdentityUpdatedEvent.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 <http://www.gnu.org/licenses/>.
+ */
+
+package net.pterodactylus.sone.freenet.wot.event
+
+import net.pterodactylus.sone.freenet.wot.*
+
+/**
+ * Event that signals that an [Identity] was updated.
+ */
+data class IdentityUpdatedEvent(val ownIdentity: OwnIdentity, val identity: Identity)
--- /dev/null
+/*
+ * Sone - OwnIdentityAddedEvent.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 <http://www.gnu.org/licenses/>.
+ */
+
+package net.pterodactylus.sone.freenet.wot.event
+
+import net.pterodactylus.sone.freenet.wot.OwnIdentity
+
+/**
+ * Event that signals that an [OwnIdentity] was added.
+ */
+data class OwnIdentityAddedEvent(val ownIdentity: OwnIdentity)
--- /dev/null
+/*
+ * Sone - OwnIdentityRemovedEvent.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 <http://www.gnu.org/licenses/>.
+ */
+
+package net.pterodactylus.sone.freenet.wot.event
+
+import net.pterodactylus.sone.freenet.wot.*
+
+/**
+ * Event that signals that an [OwnIdentity] was removed.
+ */
+data class OwnIdentityRemovedEvent(val ownIdentity: OwnIdentity)
+++ /dev/null
-package net.pterodactylus.sone.freenet.wot.event;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.not;
-import static org.mockito.Mockito.mock;
-
-import net.pterodactylus.sone.freenet.wot.Identity;
-import net.pterodactylus.sone.freenet.wot.OwnIdentity;
-
-import org.junit.Test;
-
-/**
- * Unit test for {@link IdentityEvent}.
- */
-public class IdentityEventTest {
-
- private final OwnIdentity ownIdentity = mock(OwnIdentity.class);
- private final Identity identity = mock(Identity.class);
- private final IdentityEvent identityEvent = createIdentityEvent(ownIdentity, identity);
-
- private IdentityEvent createIdentityEvent(final OwnIdentity ownIdentity, final Identity identity) {
- return new IdentityEvent(ownIdentity, identity) {
- };
- }
-
- @Test
- public void identityEventRetainsIdentities() {
- assertThat(identityEvent.ownIdentity(), is(ownIdentity));
- assertThat(identityEvent.identity(), is(identity));
- }
-
- @Test
- public void eventsWithTheSameIdentityHaveTheSameHashCode() {
- IdentityEvent secondIdentityEvent = createIdentityEvent(ownIdentity, identity);
- assertThat(identityEvent.hashCode(), is(secondIdentityEvent.hashCode()));
- }
-
- @Test
- public void eventsWithTheSameIdentitiesAreEqual() {
- IdentityEvent secondIdentityEvent = createIdentityEvent(ownIdentity, identity);
- assertThat(identityEvent, is(secondIdentityEvent));
- assertThat(secondIdentityEvent, is(identityEvent));
- }
-
- @Test
- public void nullDoesNotEqualIdentityEvent() {
- assertThat(identityEvent, not(is((Object) null)));
- }
-
-
-}
+++ /dev/null
-package net.pterodactylus.sone.freenet.wot.event;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.not;
-import static org.mockito.Mockito.mock;
-
-import net.pterodactylus.sone.freenet.wot.OwnIdentity;
-
-import org.junit.Test;
-
-/**
- * Unit test for {@link OwnIdentityEvent}.
- */
-public class OwnIdentityEventTest {
-
- private final OwnIdentity ownIdentity = mock(OwnIdentity.class);
- private final OwnIdentityEvent ownIdentityEvent = createOwnIdentityEvent(ownIdentity);
-
- @Test
- public void eventRetainsOwnIdentity() {
- assertThat(ownIdentityEvent.ownIdentity(), is(ownIdentity));
- }
-
- protected OwnIdentityEvent createOwnIdentityEvent(final OwnIdentity ownIdentity) {
- return new OwnIdentityEvent(ownIdentity) {
- };
- }
-
- @Test
- public void twoOwnIdentityEventsWithTheSameIdentityHaveTheSameHashCode() {
- OwnIdentityEvent secondOwnIdentityEvent = createOwnIdentityEvent(ownIdentity);
- assertThat(secondOwnIdentityEvent.hashCode(), is(ownIdentityEvent.hashCode()));
- }
-
- @Test
- public void ownIdentityEventDoesNotMatchNull() {
- assertThat(ownIdentityEvent, not(is((Object) null)));
- }
-
- @Test
- public void ownIdentityEventDoesNotMatchObjectWithADifferentClass() {
- assertThat(ownIdentityEvent, not(is(new Object())));
- }
-
-}