From 34a9951c246a1a48224efcb43037c4ee88b2564f Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Tue, 4 Mar 2014 20:18:32 +0100 Subject: [PATCH] Add storeSone() method to sone database. --- .../java/net/pterodactylus/sone/database/SoneDatabase.java | 4 ++++ .../net/pterodactylus/sone/database/memory/MemoryDatabase.java | 10 ++++++++++ 2 files changed, 14 insertions(+) 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 -- 2.7.4