Update years in copyright line
[Sone.git] / src / main / java / net / pterodactylus / sone / freenet / wot / DefaultOwnIdentity.java
index f89ddda..68e6f41 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Sone - DefaultOwnIdentity.java - Copyright © 2010 David Roden
+ * Sone - DefaultOwnIdentity.java - Copyright © 2010–2015 David Roden
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -17,9 +17,7 @@
 
 package net.pterodactylus.sone.freenet.wot;
 
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
+import static com.google.common.base.Preconditions.checkNotNull;
 
 /**
  * An own identity is an identity that the owner of the node has full control
@@ -29,17 +27,12 @@ import java.util.Set;
  */
 public class DefaultOwnIdentity extends DefaultIdentity implements OwnIdentity {
 
-       /** The identity manager. */
-       private final WebOfTrustConnector webOfTrustConnector;
-
        /** The insert URI of the identity. */
        private final String insertUri;
 
        /**
         * Creates a new own identity.
         *
-        * @param webOfTrustConnector
-        *            The identity manager
         * @param id
         *            The ID of the identity
         * @param nickname
@@ -49,90 +42,52 @@ public class DefaultOwnIdentity extends DefaultIdentity implements OwnIdentity {
         * @param insertUri
         *            The insert URI of the identity
         */
-       public DefaultOwnIdentity(WebOfTrustConnector webOfTrustConnector, String id, String nickname, String requestUri, String insertUri) {
-               super(webOfTrustConnector, id, nickname, requestUri);
-               this.webOfTrustConnector = webOfTrustConnector;
-               this.insertUri = insertUri;
+       public DefaultOwnIdentity(String id, String nickname, String requestUri, String insertUri) {
+               super(id, nickname, requestUri);
+               this.insertUri = checkNotNull(insertUri);
        }
 
        //
        // ACCESSORS
        //
 
-       /**
-        * {@inheritDoc}
-        */
        @Override
        public String getInsertUri() {
                return insertUri;
        }
 
-       /**
-        * {@inheritDoc}
-        */
        @Override
-       public void addContext(String context) throws WebOfTrustException {
-               webOfTrustConnector.addContext(this, context);
+       public OwnIdentity addContext(String context) {
+               return (OwnIdentity) super.addContext(context);
        }
 
-       /**
-        * {@inheritDoc}
-        */
        @Override
-       public void removeContext(String context) throws WebOfTrustException {
-               webOfTrustConnector.removeContext(this, context);
+       public OwnIdentity removeContext(String context) {
+               return (OwnIdentity) super.removeContext(context);
        }
 
-       /**
-        * {@inheritDoc}
-        */
        @Override
-       public void setContexts(Set<String> contexts) throws WebOfTrustException {
-               for (String context : getContexts()) {
-                       if (!contexts.contains(context)) {
-                               webOfTrustConnector.removeContext(this, context);
-                       }
-               }
-               for (String context : contexts) {
-                       if (!getContexts().contains(context)) {
-                               webOfTrustConnector.addContext(this, context);
-                       }
-               }
+       public OwnIdentity setProperty(String name, String value) {
+               return (OwnIdentity) super.setProperty(name, value);
        }
 
-       /**
-        * {@inheritDoc}
-        */
        @Override
-       public void setProperty(String name, String value) throws WebOfTrustException {
-               webOfTrustConnector.setProperty(this, name, value);
+       public OwnIdentity removeProperty(String name) {
+               return (OwnIdentity) super.removeProperty(name);
        }
 
-       /**
-        * {@inheritDoc}
-        */
+       //
+       // OBJECT METHODS
+       //
+
        @Override
-       public void removeProperty(String name) throws WebOfTrustException {
-               webOfTrustConnector.removeProperty(this, name);
+       public int hashCode() {
+               return super.hashCode();
        }
 
-       /**
-        * {@inheritDoc}
-        */
        @Override
-       public void setProperties(Map<String, String> properties) throws WebOfTrustException {
-               for (Entry<String, String> oldProperty : getProperties().entrySet()) {
-                       if (!properties.containsKey(oldProperty.getKey())) {
-                               webOfTrustConnector.removeProperty(this, oldProperty.getKey());
-                       } else {
-                               webOfTrustConnector.setProperty(this, oldProperty.getKey(), properties.get(oldProperty.getKey()));
-                       }
-               }
-               for (Entry<String, String> newProperty : properties.entrySet()) {
-                       if (!getProperties().containsKey(newProperty.getKey())) {
-                               webOfTrustConnector.setProperty(this, newProperty.getKey(), newProperty.getValue());
-                       }
-               }
+       public boolean equals(Object object) {
+               return super.equals(object);
        }
 
 }