X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Ffreenet%2Fwot%2FIdentity.java;fp=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Ffreenet%2Fwot%2FIdentity.java;h=4554f40f828661a26ea744318cf8c5e0f5cc12ff;hp=bc594f8c37132276643049ea742696c0e85e38ca;hb=4c4b77eff97fd247c6b1c8bbb30aeb6ea3d2c172;hpb=aefc6e983ee277ffba8eb2aad6141911e100ae54 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 bc594f8..4554f40 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/wot/Identity.java +++ b/src/main/java/net/pterodactylus/sone/freenet/wot/Identity.java @@ -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. *