package net.kleinhaneveld.fn;

import net.kleinhaneveld.fn.annotations.Lazy;

import javax.annotation.Nonnull;
import java.util.Map;

public class Functions {
    public static final Function<Object, String> TO_STRING = new Function<Object, String>() {
        @Nonnull
        @Override
        public String apply(@Nonnull Object input) {
            return input.toString();
        }
    };

    @Lazy
    @Nonnull
    public static <T, R> Function<T, Option<R>> mapper(@Nonnull final Map<T, R> map) {
        return new Function<T, Option<R>>() {
            @Nonnull
            @Override
            public Option<R> apply(@Nonnull T input) {
                return Option.of(map.get(input));
            }
        };
    }

    @Nonnull
    public static <T> Function<T, T> identity() {
        return new Function<T, T>() {
            @Nonnull
            @Override
            public T apply(@Nonnull T input) {
                return input;
            }
        };
    }
}

@@ -464,14 +464,15 @@
 R%3E%3E 
-mapper
+getFrom
 (@No
@@ -636,32 +636,32 @@
 null T input) %7B%0A
-
                 
@@ -726,16 +726,365 @@
 %0A    %7D%0A%0A
+    @Lazy%0A    @Nonnull%0A    public static %3CT, R%3E Function%3CT, Option%3CR%3E%3E getAndRemoveFrom(@Nonnull final Map%3CT, R%3E map) %7B%0A        return new Function%3CT, Option%3CR%3E%3E() %7B%0A            @Nonnull%0A            @Override%0A            public Option%3CR%3E apply(@Nonnull T input) %7B%0A                return Option.of(map.remove(input));%0A            %7D%0A        %7D;%0A    %7D%0A%0A
     @Non

Rename mapper to getFrom, and add getAndRemoveFrom function.