Add function to extract the context of a context object.
[Sone.git] / src / main / java / net / pterodactylus / sone / freenet / wot / Context.java
index 0f730fa..f72e56d 100644 (file)
 
 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<Context, String> extractContext = new Function<Context, String>() {
+               @Nullable
+               @Override
+               public String apply(@Nullable Context context) {
+                       return (context == null) ? null : context.getContext();
+               }
+       };
+
        private final String context;
 
        public Context(String context) {