Use local Sone for loading the Sone in the database.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 3 Dec 2014 05:23:44 +0000 (06:23 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 3 Dec 2014 05:23:44 +0000 (06:23 +0100)
src/main/java/net/pterodactylus/sone/database/LocalSoneDatabase.java
src/main/java/net/pterodactylus/sone/database/memory/MemoryDatabase.java

index 036c607..0240080 100644 (file)
@@ -14,7 +14,7 @@ import com.google.common.base.Optional;
 public interface LocalSoneDatabase {
 
        Optional<LocalSone> getLocalSone(String localSoneId);
-       Sone registerLocalSone(OwnIdentity ownIdentity);
+       LocalSone registerLocalSone(OwnIdentity ownIdentity);
        String getLastInsertFingerprint(Sone sone);
        void setLastInsertFingerprint(Sone sone, String lastInsertFingerprint);
 
index 128a4bd..7ad40e0 100644 (file)
@@ -173,14 +173,14 @@ public class MemoryDatabase extends AbstractService implements Database {
        }
 
        @Override
-       public Sone registerLocalSone(OwnIdentity ownIdentity) {
-               final Sone localSone = loadLocalSone(ownIdentity);
+       public LocalSone registerLocalSone(OwnIdentity ownIdentity) {
+               final LocalSone localSone = loadLocalSone(ownIdentity);
                localSones.add(ownIdentity.getId());
                return localSone;
        }
 
-       private Sone loadLocalSone(OwnIdentity ownIdentity) {
-               Sone localSone = newSoneBuilder().local().from(ownIdentity).build();
+       private LocalSone loadLocalSone(OwnIdentity ownIdentity) {
+               LocalSone localSone = (LocalSone) newSoneBuilder().local().from(ownIdentity).build();
                localSone.setLatestEdition(
                                Optional.fromNullable(
                                                Longs.tryParse(ownIdentity.getProperty(LATEST_EDITION_PROPERTY)))
@@ -192,7 +192,7 @@ public class MemoryDatabase extends AbstractService implements Database {
                return localSone;
        }
 
-       public void loadSone(Sone sone) {
+       public void loadSone(LocalSone sone) {
                long soneTime = configurationLoader.getLocalSoneTime(sone.getId());
                if (soneTime == -1) {
                        return;