package com.facebook.presto.util;

import com.google.common.base.Function;

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

public class MoreFunctions
{
    public static Function<String, String> toLowerCase()
    {
        return new Function<String, String>()
        {
            @Override
            public String apply(String s)
            {
                return s.toLowerCase();
            }
        };
    }

    public static <K, V> Function<Map.Entry<K, V>, V> valueGetter()
    {
        return new Function<Map.Entry<K, V>, V>()
        {
            @Nullable
            @Override
            public V apply(Map.Entry<K, V> input)
            {
                return input.getValue();
            }
        };
    }

    public static <K, V> Function<Map.Entry<K, V>, K> keyGetter()
    {
        return new Function<Map.Entry<K, V>, K>()
        {
            @Nullable
            @Override
            public K apply(Map.Entry<K, V> input)
            {
                return input.getKey();
            }
        };
    }

}

@@ -1050,10 +1050,284 @@
 %0A    %7D%0A%0A
+    public static %3CI, T extends I%3E Function%3CI, T%3E cast(final Class%3CT%3E clazz)%0A    %7B%0A        return new Function%3CI, T%3E()%0A        %7B%0A            @Override%0A            public T apply(I input)%0A            %7B%0A                return clazz.cast(input);%0A            %7D%0A        %7D;%0A    %7D%0A
 %7D%0A

Add "cast" utility function