package com.github.davidmoten.rx2;

import com.github.davidmoten.rx2.exceptions.ThrowingException;

import io.reactivex.functions.Function;

public final class Functions {

    private Functions() {
        // prevent instantiation
    }

    public static <T> Function<Object, T> constant(final T value) {
        return new Function<Object, T>() {

            @Override
            public T apply(Object t) throws Exception {
                return value;
            }
        };
    }

    public static <T> Function<T, T> identity() {
        // TODO make holder
        return new Function<T, T>() {

            @Override
            public T apply(T t) throws Exception {
                return t;
            }
        };
    }
    
    public static <T, R> Function<T, R> throwing() {
        //TODO make holder
        return new Function<T, R>() {

            @Override
            public R apply(T t) {
                throw new ThrowingException();
            }
        };
    }

}

@@ -498,32 +498,68 @@
    %7D;%0D%0A    %7D%0D%0A%0D%0A
+    @SuppressWarnings(%22unchecked%22)%0D%0A
     public stati
@@ -605,61 +605,207 @@
     
-// TODO make holder
+return (Function%3CT, T%3E) IdentityHolder.INSTANCE;
 %0D%0A    
+%7D%0D%0A
     
-return new Function%3CT, T
+%0D%0A    private static enum IdentityHolder %7B%0D%0A        ;%0D%0A        static final Function%3CObject,Object%3E INSTANCE = new Function%3CObject, Object
 %3E() 
@@ -855,17 +855,27 @@
 lic 
-T
+Object
  apply(
-T
+Object
  t) 

add Holders