// Path: shelly/src/main/java/xiaofei/library/shelly/Shelly.java
// public class Shelly {
// 
//     private static final TargetCenter TARGET_CENTER = TargetCenter.getInstance();
// 
//     private static final DominoCenter DOMINO_CENTER = DominoCenter.getInstance();
// 
//     public static void register(Object object) {
//         TARGET_CENTER.register(object);
//     }
// 
//     public static boolean isRegistered(Object object) {
//         return TARGET_CENTER.isRegistered(object);
//     }
// 
//     public static void unregister(Object object) {
//         TARGET_CENTER.unregister(object);
//     }
// 
//     public static <T> Domino<T, T> createDomino(Object label) {
//         return new Domino<T, T>(label);
//     }
// 
//     public static <T> Domino<T, T> createAnonymousDomino() {
//         return createDomino(null);
//     }
// 
//     @SafeVarargs
//     public static <T> void playDomino(Object label, T... input) {
//         CopyOnWriteArrayList<T> newInput = new CopyOnWriteArrayList<T>();
//         if (input == null) {
//             newInput.add(null);
//         } else if (input.length > 0) {
//             newInput.addAll(Arrays.asList(input));
//         }
//         playDominoInternal(label, newInput);
//     }
// 
//     public static void playDomino(Object label) {
//         playDominoInternal(label, new CopyOnWriteArrayList<Object>());
//     }
// 
//     private static <T> void playDominoInternal(Object label, CopyOnWriteArrayList<T> input) {
//         DOMINO_CENTER.play(label, input);
//     }
// 
//     public static <T, R> Domino<T, R> getDominoByLabel(Object label) {
//         return DOMINO_CENTER.getDomino(label);
//     }
// }
// 
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action1.java
// public interface Action1<T> extends Action {
//     void call(T input);
// }
// 
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action2.java
// public interface Action2<T, R> extends Action {
//     void call(T input1, R input2);
// }
// 
// Path: shelly/src/main/java/xiaofei/library/shelly/function/TargetAction1.java
// public interface TargetAction1<T, R> extends Action {
//     void call(T t, R input);
// }
// 
// Path: shelly/src/main/java/xiaofei/library/shelly/function/TargetAction2.java
// public interface TargetAction2<T, R, S> extends Action {
//     void call(T t, R input1, S input2);
// }
// 
// Path: shelly/src/main/java/xiaofei/library/shelly/task/RetrofitTask.java
// public abstract class RetrofitTask<T, R> extends AbstractRetrofitTask<T, R> {
//     @Override
//     protected void call(Call<R> call) {
//         call.enqueue(getCallback());
//     }
// 
// }
// 
// Path: shelly/src/main/java/xiaofei/library/shelly/tuple/Pair.java
// public class Pair<T1, T2> {
//     public final T1 first;
//     public final T2 second;
// 
//     @Deprecated
//     public Pair(T1 first, T2 second) {
//         this.first = first;
//         this.second = second;
//     }
// 
//     public static <T1, T2> Pair<T1, T2> create(T1 first, T2 second) {
//         return new Pair<T1, T2>(first, second);
//     }
// }
// 
// Path: shelly/src/main/java/xiaofei/library/shelly/tuple/Triple.java
// public class Triple<T1, T2, T3> {
//     public final T1 first;
//     public final T2 second;
//     public final T3 third;
// 
//     @Deprecated
//     public Triple(T1 first, T2 second, T3 third) {
//         this.first = first;
//         this.second = second;
//         this.third = third;
//     }
// 
//     public static <T1, T2, T3> Triple<T1, T2, T3> create(T1 first, T2 second, T3 third) {
//         return new Triple<T1, T2, T3>(first, second, third);
//     }
// }


import xiaofei.library.shelly.function.TargetAction1;
import xiaofei.library.shelly.function.TargetAction2;
import xiaofei.library.shelly.task.RetrofitTask;
import xiaofei.library.shelly.tuple.Pair;
import xiaofei.library.shelly.tuple.Triple;
import android.app.Activity;
import android.util.Log;
import android.widget.Toast;
import java.io.IOException;
import java.util.Objects;
import retrofit2.Call;
import retrofit2.Response;
import xiaofei.library.shelly.Shelly;
import xiaofei.library.shelly.function.Action1;
import xiaofei.library.shelly.function.Action2;
public class UserService {

    public static final Object SIGN_UP = new Object();
    public static final Object SIGN_IN = new Object();
    public static final Object SIGN_OUT = new Object();

    public static void init() {
        final UserNetwork userNetwork = null;
        Shelly.<Pair<String, String>>createDomino(SIGN_UP)
                .background()
                .beginRetrofitTaskKeepingInput(new RetrofitTask<Pair<String,String>, String>() {
                    @Override
                    protected Call<String> getCall(Pair<String, String> input) {
                        return userNetwork.signUp(input.first, input.second);
                    }
                })
                .background()
                .onSuccessResult(new Action2<Pair<String, String>, String>() {
                    @Override
                    public void call(Pair<String, String> input1, String token) {
                        // Store the token.
                    }
                })
                .uiThread()
                .onSuccessResult(HomeActivity.class, new TargetAction2<HomeActivity, Pair<String, String>, String>() {
                    @Override
                    public void call(HomeActivity homeActivity, Pair<String, String> input1, String token) {
                        homeActivity.signUp(input1.first, token);
                    }
                })
// Path: shelly/src/main/java/xiaofei/library/shelly/Shelly.java
// public class Shelly {
// 
//     private static final TargetCenter TARGET_CENTER = TargetCenter.getInstance();
// 
//     private static final DominoCenter DOMINO_CENTER = DominoCenter.getInstance();
// 
//     public static void register(Object object) {
//         TARGET_CENTER.register(object);
//     }
// 
//     public static boolean isRegistered(Object object) {
//         return TARGET_CENTER.isRegistered(object);
//     }
// 
//     public static void unregister(Object object) {
//         TARGET_CENTER.unregister(object);
//     }
// 
//     public static <T> Domino<T, T> createDomino(Object label) {
//         return new Domino<T, T>(label);
//     }
// 
//     public static <T> Domino<T, T> createAnonymousDomino() {
//         return createDomino(null);
//     }
// 
//     @SafeVarargs
//     public static <T> void playDomino(Object label, T... input) {
//         CopyOnWriteArrayList<T> newInput = new CopyOnWriteArrayList<T>();
//         if (input == null) {
//             newInput.add(null);
//         } else if (input.length > 0) {
//             newInput.addAll(Arrays.asList(input));
//         }
//         playDominoInternal(label, newInput);
//     }
// 
//     public static void playDomino(Object label) {
//         playDominoInternal(label, new CopyOnWriteArrayList<Object>());
//     }
// 
//     private static <T> void playDominoInternal(Object label, CopyOnWriteArrayList<T> input) {
//         DOMINO_CENTER.play(label, input);
//     }
// 
//     public static <T, R> Domino<T, R> getDominoByLabel(Object label) {
//         return DOMINO_CENTER.getDomino(label);
//     }
// }
// 
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action1.java
// public interface Action1<T> extends Action {
//     void call(T input);
// }
// 
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action2.java
// public interface Action2<T, R> extends Action {
//     void call(T input1, R input2);
// }
// 
// Path: shelly/src/main/java/xiaofei/library/shelly/function/TargetAction1.java
// public interface TargetAction1<T, R> extends Action {
//     void call(T t, R input);
// }
// 
// Path: shelly/src/main/java/xiaofei/library/shelly/function/TargetAction2.java
// public interface TargetAction2<T, R, S> extends Action {
//     void call(T t, R input1, S input2);
// }
// 
// Path: shelly/src/main/java/xiaofei/library/shelly/task/RetrofitTask.java
// public abstract class RetrofitTask<T, R> extends AbstractRetrofitTask<T, R> {
//     @Override
//     protected void call(Call<R> call) {
//         call.enqueue(getCallback());
//     }
// 
// }
// 
// Path: shelly/src/main/java/xiaofei/library/shelly/tuple/Pair.java
// public class Pair<T1, T2> {
//     public final T1 first;
//     public final T2 second;
// 
//     @Deprecated
//     public Pair(T1 first, T2 second) {
//         this.first = first;
//         this.second = second;
//     }
// 
//     public static <T1, T2> Pair<T1, T2> create(T1 first, T2 second) {
//         return new Pair<T1, T2>(first, second);
//     }
// }
// 
// Path: shelly/src/main/java/xiaofei/library/shelly/tuple/Triple.java
// public class Triple<T1, T2, T3> {
//     public final T1 first;
//     public final T2 second;
//     public final T3 third;
// 
//     @Deprecated
//     public Triple(T1 first, T2 second, T3 third) {
//         this.first = first;
//         this.second = second;
//         this.third = third;
//     }
// 
//     public static <T1, T2, T3> Triple<T1, T2, T3> create(T1 first, T2 second, T3 third) {
//         return new Triple<T1, T2, T3>(first, second, third);
//     }
// }


// Path: shelly/src/test/java/xiaofei/library/shelly/demo/UserService.java
import xiaofei.library.shelly.function.TargetAction1;
import xiaofei.library.shelly.function.TargetAction2;
import xiaofei.library.shelly.task.RetrofitTask;
import xiaofei.library.shelly.tuple.Pair;
import xiaofei.library.shelly.tuple.Triple;
import android.app.Activity;
import android.util.Log;
import android.widget.Toast;
import java.io.IOException;
import java.util.Objects;
import retrofit2.Call;
import retrofit2.Response;
import xiaofei.library.shelly.Shelly;
import xiaofei.library.shelly.function.Action1;
import xiaofei.library.shelly.function.Action2;

public class UserService {

    public static final Object SIGN_UP = new Object();
    public static final Object SIGN_IN = new Object();
    public static final Object SIGN_OUT = new Object();

    public static void init() {
        final UserNetwork userNetwork = null;
        Shelly.<Pair<String, String>>createDomino(SIGN_UP)
                .background()
                .beginRetrofitTaskKeepingInput(new RetrofitTask<Pair<String,String>, String>() {
                    @Override
                    protected Call<String> getCall(Pair<String, String> input) {
                        return userNetwork.signUp(input.first, input.second);
                    }
                })
                .background()
                .onSuccessResult(new Action2<Pair<String, String>, String>() {
                    @Override
                    public void call(Pair<String, String> input1, String token) {
                        // Store the token.
                    }
                })
                .uiThread()
                .onSuccessResult(HomeActivity.class, new TargetAction2<HomeActivity, Pair<String, String>, String>() {
                    @Override
                    public void call(HomeActivity homeActivity, Pair<String, String> input1, String token) {
                        homeActivity.signUp(input1.first, token);
                    }
                })
                .onResponseFailure(HomeActivity.class, new TargetAction2<HomeActivity, Pair<String, String>, Response<String>>() {