/*
- * Sone - Identity.java - Copyright © 2010–2012 David Roden
+ * Sone - Identity.java - Copyright © 2010–2013 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
package net.pterodactylus.sone.freenet.wot;
import java.util.Collection;
+import java.util.Collections;
import java.util.Map;
import java.util.Set;
+import javax.annotation.Nullable;
+
+import com.google.common.base.Function;
+
/**
* Interface for web of trust identities, defining all functions that can be
* performed on an identity. An identity is only a container for identity data
*/
public interface Identity {
+ final Function<Identity, Collection<String>> TO_CONTEXTS = new Function<Identity, Collection<String>>() {
+ @Override
+ public Collection<String> apply(@Nullable Identity identity) {
+ return (identity == null) ? Collections.<String>emptyList() : identity.getContexts();
+ }
+ };
+
+ final Function<Identity, Map<String, String>> TO_PROPERTIES = new Function<Identity, Map<String, String>>() {
+ @Override
+ public Map<String, String> apply(@Nullable Identity identity) {
+ return (identity == null) ? Collections.<String, String>emptyMap() : identity.getProperties();
+ }
+ };
+
/**
* Returns the ID of the identity.
*