// 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/Action0.java
// public interface Action0 extends Action {
//     void call();
// }
// 
// 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/TargetAction0.java
// public interface TargetAction0<T> extends Action {
//     void call(T t);
// }
// 
// 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/task/Task.java
// public abstract class Task<T, R, S> {
// 
//     private TaskListener<R, S> mListener;
// 
//     public Task() {
//     }
// 
//     public void setListener(TaskListener<R, S> listener) {
//         mListener = listener;
//     }
// 
//     protected abstract void onExecute(T input);
// 
//     public final void execute(T input) {
//         onExecute(input);
//     }
// 
//     public final void notifySuccess(R result) {
//         if (mListener != null) {
//             mListener.onSuccess(result);
//         }
//     }
// 
//     public final void notifyFailure(S error) {
//         if (mListener != null) {
//             mListener.onFailure(error);
//         }
//     }
// 
//     public interface TaskListener<R, S> {
//         void onSuccess(R result);
//         void onFailure(S error);
//     }
// 
// }


import org.junit.Test;
import java.util.concurrent.TimeUnit;
import xiaofei.library.shelly.Shelly;
import xiaofei.library.shelly.function.Action0;
import xiaofei.library.shelly.function.Action1;
import xiaofei.library.shelly.function.TargetAction0;
import xiaofei.library.shelly.function.TargetAction1;
import xiaofei.library.shelly.task.Task;
                        System.out.println("2: " + Thread.currentThread().getName() + " " + input);
                        if (input.length() == 1) {
                            notifySuccess(input.charAt(0));
                        } else {
                            notifyFailure(input.charAt(0) - 'A');
                        }
                    }
                })
                .onSuccess(Shelly.<Character>createAnonymousDomino()
                            .background()
                            .perform(new Action1<Character>() {
                                @Override
                                public void call(Character input) {
                                    System.out.println("3: " + Thread.currentThread().getName() + " " + input);
                                }
                            }))
                .newThread()
                .onSuccess(new Action0() {
                    @Override
                    public void call() {
                        System.out.println("4: " + Thread.currentThread().getName());
                    }
                })
                .onSuccess(new Action1<Character>() {
                    @Override
                    public void call(Character input) {
                        System.out.println("5: " + Thread.currentThread().getName() + " " + input);
                    }
                })
                .background()
// 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/Action0.java
// public interface Action0 extends Action {
//     void call();
// }
// 
// 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/TargetAction0.java
// public interface TargetAction0<T> extends Action {
//     void call(T t);
// }
// 
// 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/task/Task.java
// public abstract class Task<T, R, S> {
// 
//     private TaskListener<R, S> mListener;
// 
//     public Task() {
//     }
// 
//     public void setListener(TaskListener<R, S> listener) {
//         mListener = listener;
//     }
// 
//     protected abstract void onExecute(T input);
// 
//     public final void execute(T input) {
//         onExecute(input);
//     }
// 
//     public final void notifySuccess(R result) {
//         if (mListener != null) {
//             mListener.onSuccess(result);
//         }
//     }
// 
//     public final void notifyFailure(S error) {
//         if (mListener != null) {
//             mListener.onFailure(error);
//         }
//     }
// 
//     public interface TaskListener<R, S> {
//         void onSuccess(R result);
//         void onFailure(S error);
//     }
// 
// }


// Path: shelly/src/test/java/xiaofei/library/shelly/domino/Test06.java
import org.junit.Test;
import java.util.concurrent.TimeUnit;
import xiaofei.library.shelly.Shelly;
import xiaofei.library.shelly.function.Action0;
import xiaofei.library.shelly.function.Action1;
import xiaofei.library.shelly.function.TargetAction0;
import xiaofei.library.shelly.function.TargetAction1;
import xiaofei.library.shelly.task.Task;

                        System.out.println("2: " + Thread.currentThread().getName() + " " + input);
                        if (input.length() == 1) {
                            notifySuccess(input.charAt(0));
                        } else {
                            notifyFailure(input.charAt(0) - 'A');
                        }
                    }
                })
                .onSuccess(Shelly.<Character>createAnonymousDomino()
                            .background()
                            .perform(new Action1<Character>() {
                                @Override
                                public void call(Character input) {
                                    System.out.println("3: " + Thread.currentThread().getName() + " " + input);
                                }
                            }))
                .newThread()
                .onSuccess(new Action0() {
                    @Override
                    public void call() {
                        System.out.println("4: " + Thread.currentThread().getName());
                    }
                })
                .onSuccess(new Action1<Character>() {
                    @Override
                    public void call(Character input) {
                        System.out.println("5: " + Thread.currentThread().getName() + " " + input);
                    }
                })
                .background()
                .onSuccess(A.class, new TargetAction0<A>() {