- * This method is only called by the {@link IdentityManager}.
- *
- * @param contexts
- * The contexts to set
- */
- void setContextsPrivate(Set
- * This method is only called by the {@link IdentityManager}.
- *
- * @param context
- * The context to add
- */
- void addContextPrivate(String context) {
+ @Override
+ public void setContexts(Collection
- * This method is only called by the {@link IdentityManager}.
- *
- * @param context
- * The context to remove
- */
- public void removeContextPrivate(String context) {
+ @Override
+ public Identity removeContext(String context) {
contexts.remove(context);
+ return this;
}
- /**
- * {@inheritDoc}
- */
@Override
public Map
- * This method is only called by the {@link IdentityManager}.
- *
- * @param properties
- * The new properties of this identity
- */
- void setPropertiesPrivate(Map
- * This method is only called by the {@link IdentityManager}.
- *
- * @param name
- * The name of the property
- * @param value
- * The value of the property
- */
- void setPropertyPrivate(String name, String value) {
- synchronized (properties) {
- properties.put(name, value);
- }
+ @Override
+ public String getProperty(String name) {
+ return properties.get(name);
}
- /**
- * {@inheritDoc}
- */
@Override
- public String getProperty(String name) {
- synchronized (properties) {
- return properties.get(name);
- }
+ public Identity setProperty(String name, String value) {
+ properties.put(name, value);
+ return this;
}
- /**
- * Removes the property with the given name.
- *
- * This method is only called by the {@link IdentityManager}.
- *
- * @param name
- * The name of the property to remove
- */
- void removePropertyPrivate(String name) {
- synchronized (properties) {
- properties.remove(name);
- }
+ @Override
+ public Identity removeProperty(String name) {
+ properties.remove(name);
+ return this;
}
- /**
- * {@inheritDoc}
- */
@Override
public Trust getTrust(OwnIdentity ownIdentity) {
- try {
- synchronized (trustCache) {
- return trustCache.get(ownIdentity);
- }
- } catch (CacheException ce1) {
- logger.log(Level.WARNING, String.format("Could not get trust for OwnIdentity: %s", ownIdentity), ce1);
- return null;
- }
+ return trustCache.get(ownIdentity);
}
- /**
- * 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) {
- synchronized (trustCache) {
- trustCache.put(ownIdentity, trust);
- }
+ @Override
+ public Identity setTrust(OwnIdentity ownIdentity, Trust trust) {
+ trustCache.put(ownIdentity, trust);
+ return this;
+ }
+
+ @Override
+ public Identity removeTrust(OwnIdentity ownIdentity) {
+ trustCache.remove(ownIdentity);
+ return this;
}
//
// OBJECT METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
public int hashCode() {
- return id.hashCode();
+ return getId().hashCode();
}
- /**
- * {@inheritDoc}
- */
@Override
public boolean equals(Object object) {
- if (!(object instanceof DefaultIdentity)) {
+ if (!(object instanceof Identity)) {
return false;
}
- DefaultIdentity identity = (DefaultIdentity) object;
- return identity.id.equals(id);
+ Identity identity = (Identity) object;
+ return identity.getId().equals(getId());
}
- /**
- * {@inheritDoc}
- */
@Override
public String toString() {
return getClass().getSimpleName() + "[id=" + id + ",nickname=" + nickname + ",contexts=" + contexts + ",properties=" + properties + "]";