From: David ‘Bombe’ Roden Date: Mon, 5 Feb 2018 20:39:35 +0000 (+0100) Subject: Don’t hand in a SoneProvider to a class that is going to be the SoneProvider X-Git-Tag: v79^2~148 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=a6ced7a625540c5ac78568281d56afc4deb65d39;p=Sone.git Don’t hand in a SoneProvider to a class that is going to be the SoneProvider --- diff --git a/src/main/java/net/pterodactylus/sone/database/memory/MemoryDatabase.java b/src/main/java/net/pterodactylus/sone/database/memory/MemoryDatabase.java index 5e5021c..07bcf2f 100644 --- a/src/main/java/net/pterodactylus/sone/database/memory/MemoryDatabase.java +++ b/src/main/java/net/pterodactylus/sone/database/memory/MemoryDatabase.java @@ -55,7 +55,6 @@ import net.pterodactylus.sone.database.PostBuilder; import net.pterodactylus.sone.database.PostDatabase; import net.pterodactylus.sone.database.PostReplyBuilder; import net.pterodactylus.sone.database.SoneBuilder; -import net.pterodactylus.sone.database.SoneProvider; import net.pterodactylus.util.config.Configuration; import net.pterodactylus.util.config.ConfigurationException; @@ -80,9 +79,6 @@ public class MemoryDatabase extends AbstractService implements Database { /** The lock. */ private final ReadWriteLock lock = new ReentrantReadWriteLock(); - /** The Sone provider. */ - private final SoneProvider soneProvider; - /** The configuration. */ private final Configuration configuration; private final ConfigurationLoader configurationLoader; @@ -125,14 +121,11 @@ public class MemoryDatabase extends AbstractService implements Database { /** * Creates a new memory database. * - * @param soneProvider - * The Sone provider * @param configuration * The configuration for loading and saving elements */ @Inject - public MemoryDatabase(SoneProvider soneProvider, Configuration configuration) { - this.soneProvider = soneProvider; + public MemoryDatabase(Configuration configuration) { this.configuration = configuration; this.configurationLoader = new ConfigurationLoader(configuration); memoryBookmarkDatabase = @@ -371,7 +364,7 @@ public class MemoryDatabase extends AbstractService implements Database { /** {@inheritDocs} */ @Override public PostBuilder newPostBuilder() { - return new MemoryPostBuilder(this, soneProvider); + return new MemoryPostBuilder(this, this); } // @@ -444,7 +437,7 @@ public class MemoryDatabase extends AbstractService implements Database { /** {@inheritDocs} */ @Override public PostReplyBuilder newPostReplyBuilder() { - return new MemoryPostReplyBuilder(this, soneProvider); + return new MemoryPostReplyBuilder(this, this); } // diff --git a/src/test/java/net/pterodactylus/sone/database/memory/MemoryDatabaseTest.java b/src/test/java/net/pterodactylus/sone/database/memory/MemoryDatabaseTest.java index bb62eaf..4d88429 100644 --- a/src/test/java/net/pterodactylus/sone/database/memory/MemoryDatabaseTest.java +++ b/src/test/java/net/pterodactylus/sone/database/memory/MemoryDatabaseTest.java @@ -75,7 +75,7 @@ public class MemoryDatabaseTest { private static final String SONE_ID = "sone"; private static final String RECIPIENT_ID = "recipient"; private final Configuration configuration = mock(Configuration.class); - private final MemoryDatabase memoryDatabase = new MemoryDatabase(null, configuration); + private final MemoryDatabase memoryDatabase = new MemoryDatabase(configuration); private final Sone sone = mock(Sone.class); @Before