From: David ‘Bombe’ Roden Date: Tue, 4 Mar 2014 19:18:32 +0000 (+0100) Subject: Add storeSone() method to sone database. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=34a9951c246a1a48224efcb43037c4ee88b2564f;p=Sone.git Add storeSone() method to sone database. --- diff --git a/src/main/java/net/pterodactylus/sone/database/SoneDatabase.java b/src/main/java/net/pterodactylus/sone/database/SoneDatabase.java index 825be32..7ee7d9b 100644 --- a/src/main/java/net/pterodactylus/sone/database/SoneDatabase.java +++ b/src/main/java/net/pterodactylus/sone/database/SoneDatabase.java @@ -17,6 +17,8 @@ package net.pterodactylus.sone.database; +import net.pterodactylus.sone.data.Sone; + /** * Combines a {@link SoneProvider} and a {@link SoneBuilderFactory} into a Sone * database. @@ -25,4 +27,6 @@ package net.pterodactylus.sone.database; */ public interface SoneDatabase extends SoneProvider, SoneBuilderFactory { + void storeSone(Sone sone); + } 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 df39511..edadf61 100644 --- a/src/main/java/net/pterodactylus/sone/database/memory/MemoryDatabase.java +++ b/src/main/java/net/pterodactylus/sone/database/memory/MemoryDatabase.java @@ -238,6 +238,16 @@ public class MemoryDatabase extends AbstractService implements Database { } @Override + public void storeSone(Sone sone) { + lock.writeLock().lock(); + try { + sones.put(sone.getId(), sone); + } finally { + lock.writeLock().unlock(); + } + } + + @Override public SoneBuilder newSoneBuilder() { return new DefaultSoneBuilder(this) { @Override