Add method to set the trust received by an OwnIdentity.
[Sone.git] / src / main / java / net / pterodactylus / sone / freenet / wot / DefaultIdentity.java
index d262d57..dcafb18 100644 (file)
@@ -24,12 +24,12 @@ import java.util.Map;
 import java.util.Set;
 
 import net.pterodactylus.sone.freenet.plugin.PluginException;
-import net.pterodactylus.util.cache.Cache;
 import net.pterodactylus.util.cache.CacheException;
 import net.pterodactylus.util.cache.CacheItem;
 import net.pterodactylus.util.cache.DefaultCacheItem;
 import net.pterodactylus.util.cache.MemoryCache;
 import net.pterodactylus.util.cache.ValueRetriever;
+import net.pterodactylus.util.cache.WritableCache;
 
 /**
  * A Web of Trust identity.
@@ -57,7 +57,7 @@ public class DefaultIdentity implements Identity {
        private final Map<String, String> properties = Collections.synchronizedMap(new HashMap<String, String>());
 
        /** Cached trust. */
-       private final Cache<OwnIdentity, Trust> trustCache = new MemoryCache<OwnIdentity, Trust>(new ValueRetriever<OwnIdentity, Trust>() {
+       private final WritableCache<OwnIdentity, Trust> trustCache = new MemoryCache<OwnIdentity, Trust>(new ValueRetriever<OwnIdentity, Trust>() {
 
                @Override
                @SuppressWarnings("synthetic-access")
@@ -248,6 +248,18 @@ public class DefaultIdentity implements Identity {
                }
        }
 
+       /**
+        * Sets the trust received for this identity by the given own identity.
+        *
+        * @param ownIdentity
+        *            The own identity that gives the trust
+        * @param trust
+        *            The trust received for this identity
+        */
+       void setTrustPrivate(OwnIdentity ownIdentity, Trust trust) {
+               trustCache.put(ownIdentity, trust);
+       }
+
        //
        // OBJECT METHODS
        //