Remove Sone instance from SoneUpdater interface.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 12 Sep 2014 20:54:26 +0000 (22:54 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 12 Sep 2014 20:54:26 +0000 (22:54 +0200)
This will probably allow the Sone parameter in the registerUsk() method
in the FreenetInterface to be removed rather soonish.

src/main/java/net/pterodactylus/sone/core/FreenetInterface.java
src/main/java/net/pterodactylus/sone/core/SoneDownloaderImpl.java
src/main/java/net/pterodactylus/sone/core/SoneUpdater.java
src/test/java/net/pterodactylus/sone/core/FreenetInterfaceTest.java

index b0c108a..b389587 100644 (file)
@@ -191,7 +191,7 @@ public class FreenetInterface {
                                @SuppressWarnings("synthetic-access")
                                public void onFoundEdition(long edition, USK key, ObjectContainer objectContainer, ClientContext clientContext, boolean metadata, short codec, byte[] data, boolean newKnownGood, boolean newSlotToo) {
                                        logger.log(Level.FINE, String.format("Found USK update for Sone “%s” at %s, new known good: %s, new slot too: %s.", sone, key, newKnownGood, newSlotToo));
-                                       soneUpdater.updateSone(sone, edition);
+                                       soneUpdater.updateSone(edition);
                                }
 
                                @Override
index fed6528..d59f1f5 100644 (file)
@@ -99,13 +99,13 @@ public class SoneDownloaderImpl extends AbstractService implements SoneDownloade
         *              The Sone to add
         */
        @Override
-       public void addSone(Sone sone) {
+       public void addSone(final Sone sone) {
                if (!sones.add(sone)) {
                        freenetInterface.unregisterUsk(sone);
                }
                freenetInterface.registerUsk(sone, new SoneUpdater() {
                        @Override
-                       public void updateSone(Sone sone, long edition) {
+                       public void updateSone(long edition) {
                                if (edition > sone.getLatestEdition()) {
                                        sone.setLatestEdition(edition);
                                        new Thread(fetchSoneAction(sone),
index 58c38f5..5cdefbe 100644 (file)
@@ -10,6 +10,6 @@ import net.pterodactylus.sone.data.Sone;
  */
 public interface SoneUpdater {
 
-       void updateSone(Sone sone, long edition);
+       void updateSone(long edition);
 
 }
index e92054a..d2a1121 100644 (file)
@@ -293,7 +293,7 @@ public class FreenetInterfaceTest {
        public void callbackForRegisteredSoneWithHigherEditionTriggersDownload() throws InterruptedException {
                freenetInterface.registerUsk(sone, soneUpdater);
                callbackCaptor.getValue().onFoundEdition(1, null, null, null, false, (short) 0, null, false, false);
-               verify(soneUpdater).updateSone(sone, 1);
+               verify(soneUpdater).updateSone(1);
        }
 
        @Test