package rx.parse;

import com.parse.*;
/*
import com.parse.FindCallback;
import com.parse.GetCallback;
import com.parse.SaveCallback;
import com.parse.ParseObject;
import com.parse.ParseException;
*/

import java.util.List;

/**
 * getInBackground(GetCallback callback)
 * findInBackground(FindCallback callback) // abstract class
 * findInBackground((list, e) -> {;})
 * findInBackground(CallbackUtils.create((list, e) -> {} ))
 */
public class Callbacks {
    public interface IFindCallback<E> {
        void done(List<E> list, ParseException e);
    }

    public interface IGetCallback<E> {
        void done(E emit, ParseException e);
    }

    public interface ISaveCallback {
        void done(ParseException e);
    }

    public interface ICountCallback {
        void done(int count, ParseException e);
    }

    public interface ILogInCallback {
        void done(ParseUser user, ParseException e);
    }

    public interface IFunctionCallback<E> {
        void done(E emit, ParseException e);
    }

    public static <T extends ParseObject> FindCallback<T> find(IFindCallback<T> callback) {
        return new FindCallback<T>() {
            @Override public void done(List<T> list, ParseException e) {
                callback.done(list, e);
            }
        };
    }

    public static <T extends ParseObject> GetCallback<T> get(IGetCallback<T> callback) {
        return new GetCallback<T>() {
            @Override public void done(T emit, ParseException e) {
                callback.done(emit, e);
            }
        };
    }

    public static SaveCallback save(ISaveCallback callback) {
        return new SaveCallback() {
            @Override public void done(ParseException e) {
                callback.done(e);
            }
        };
    }

    public static CountCallback count(ICountCallback callback) {
        return new CountCallback() {
            @Override public void done(int count, ParseException e) {
                callback.done(count, e);
            }
        };
    }

    public static LogInCallback login(ILogInCallback callback) {
        return new LogInCallback() {
            @Override public void done(ParseUser user, ParseException e) {
                callback.done(user, e);
            }
        };
    }

    public static <T> FunctionCallback function(IFunctionCallback<T> callback) {
        return new FunctionCallback<T>() {
            @Override public void done(T emit, ParseException e) {
                callback.done(emit, e);
            }
        };
    }
}

@@ -36,1062 +36,205 @@
 .*;%0A
-/*%0A
 import 
-com.parse.FindCallback;%0Aimport com.parse.GetCallback;%0Aimport com.parse.SaveCallback;%0Aimport com.parse.ParseObject;%0Aimport com.parse.ParseException;%0A*/%0A%0Aimport java.util.List;%0A%0A/**%0A * getInBackground(GetCallback callback)%0A * findInBackground(FindCallback callback) // abstract class%0A * findInBackground((list, e) -%3E %7B;%7D)%0A * findInBackground(CallbackUtils.create((list, e) -%3E %7B%7D ))%0A */%0Apublic class Callbacks %7B%0A    public interface IFindCallback%3CE%3E %7B%0A        void done(List%3CE%3E list, ParseException e);%0A    %7D%0A%0A    public interface IGetCallback%3CE%3E %7B%0A        void done(E emit, ParseException e);%0A    %7D%0A%0A    public interface ISaveCallback %7B%0A        void done(ParseException e);%0A    %7D%0A%0A    public interface ICountCallback %7B%0A        void done(int count, ParseException e);%0A    %7D%0A%0A    public interface ILogInCallback %7B%0A        void done(ParseUser user, ParseException e);%0A    %7D%0A%0A    public interface IFunctionCallback%3CE%3E %7B%0A        void done(E emit, ParseException e);%0A    %7D%0A%0A    public static %3CT extends ParseObject%3E FindCallback%3CT%3E find(IFindCallback%3CT
+rx.functions.*;%0A%0Aimport java.util.List;%0A%0A/**%0A * For lambda%0A */%0Apublic class Callbacks %7B%0A    public static %3CT extends ParseObject%3E FindCallback%3CT%3E find(Action2%3CList%3CT%3E, ? super ParseException
 %3E ca
@@ -380,20 +380,20 @@
 allback.
-done
+call
 (list, e
@@ -492,22 +492,49 @@
 get(
-IGetCallback%3CT
+Action2%3C? super T, ? super ParseException
 %3E ca
@@ -665,36 +665,36 @@
        callback.
-done
+call
 (emit, e);%0A     
@@ -760,21 +760,39 @@
 ave(
-ISaveCallback
+Action1%3C? super ParseException%3E
  cal
@@ -920,20 +920,20 @@
 allback.
-done
+call
 (e);%0A   
@@ -1003,22 +1003,56 @@
 unt(
-ICountCallback
+Action2%3C? super Integer, ? super ParseException%3E
  cal
@@ -1192,20 +1192,20 @@
 allback.
-done
+call
 (count, 
@@ -1282,22 +1282,58 @@
 gin(
-ILogInCallback
+Action2%3C? super ParseUser, ? super ParseException%3E
  cal
@@ -1478,20 +1478,20 @@
 allback.
-done
+call
 (user, e
@@ -1544,17 +1544,17 @@
 static %3C
-T
+R
 %3E Functi
@@ -1577,27 +1577,49 @@
 ion(
-IFun
+A
 ction
-Callback%3CT
+2%3C? super R, ? super ParseException
 %3E ca
@@ -1656,33 +1656,33 @@
 unctionCallback%3C
-T
+R
 %3E() %7B%0A          
@@ -1702,33 +1702,33 @@
 ublic void done(
-T
+R
  emit, ParseExce
@@ -1763,20 +1763,20 @@
 allback.
-done
+call
 (emit, e

Remove unnecessary interfaces