X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Ffreenet%2Fwot%2FIdentity.java;h=4554f40f828661a26ea744318cf8c5e0f5cc12ff;hb=4c4b77eff97fd247c6b1c8bbb30aeb6ea3d2c172;hp=2849da91fb3bf6bc8a6a4dbbfc86a620811e5c98;hpb=17ed3b897e37c8b16c559b79bfe97d32a7605bfb;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/freenet/wot/Identity.java b/src/main/java/net/pterodactylus/sone/freenet/wot/Identity.java index 2849da9..4554f40 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/wot/Identity.java +++ b/src/main/java/net/pterodactylus/sone/freenet/wot/Identity.java @@ -1,5 +1,5 @@ /* - * 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 @@ -18,9 +18,14 @@ 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 @@ -30,6 +35,20 @@ import java.util.Set; */ public interface Identity { + final Function> TO_CONTEXTS = new Function>() { + @Override + public Collection apply(@Nullable Identity identity) { + return (identity == null) ? Collections.emptyList() : identity.getContexts(); + } + }; + + final Function> TO_PROPERTIES = new Function>() { + @Override + public Map apply(@Nullable Identity identity) { + return (identity == null) ? Collections.emptyMap() : identity.getProperties(); + } + }; + /** * Returns the ID of the identity. *