From 6ee1495f002df5e312c754df56d384d48b9261ee Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 27 Jun 2014 18:30:58 +0200 Subject: [PATCH] Add function to extract the context of a context object. --- .../java/net/pterodactylus/sone/freenet/wot/Context.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/net/pterodactylus/sone/freenet/wot/Context.java b/src/main/java/net/pterodactylus/sone/freenet/wot/Context.java index 0f730fa..f72e56d 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/wot/Context.java +++ b/src/main/java/net/pterodactylus/sone/freenet/wot/Context.java @@ -17,6 +17,10 @@ package net.pterodactylus.sone.freenet.wot; +import javax.annotation.Nullable; + +import com.google.common.base.Function; + /** * Custom container for the Web of Trust context. This allows easier * configuration of dependency injection. @@ -25,6 +29,14 @@ package net.pterodactylus.sone.freenet.wot; */ public class Context { + public static final Function extractContext = new Function() { + @Nullable + @Override + public String apply(@Nullable Context context) { + return (context == null) ? null : context.getContext(); + } + }; + private final String context; public Context(String context) { -- 2.7.4