// 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/Function1.java
// public interface Function1<T, R> extends Function {
//     R call(T input);
// }
// 
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Function2.java
// public interface Function2<T, R, S> extends Function {
//     S 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);
// }


import org.junit.Test;
import xiaofei.library.shelly.Shelly;
import xiaofei.library.shelly.function.Action1;
import xiaofei.library.shelly.function.Function1;
import xiaofei.library.shelly.function.Function2;
import xiaofei.library.shelly.function.TargetAction1;
    public void testMap() {
        A a1 = new A(1), a2 = new B(2);
        Shelly.register(a1);
        Shelly.register(a2);
        Shelly.<A>createDomino(2)
                .perform(new Action1<A>() {
                    @Override
                    public void call(A input) {
                        System.out.println("1: " + input.getX());
                    }
                })
                .map(A.class, new Function2<A, A, String>() {
                    @Override
                    public String call(A input1, A input2) {
                        return "" + input1.getX() + " " + input2.getX();
                    }
                })
                .perform(new Action1<String>() {
                    @Override
                    public void call(String input) {
                        System.out.println("2: " + input);
                    }
                })
                .commit();
        Shelly.playDomino(2, a1, a2);
    }

    @Test
    public void testBackgroundQueue() {
        Shelly.<String>createDomino(3)
// 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/Function1.java
// public interface Function1<T, R> extends Function {
//     R call(T input);
// }
// 
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Function2.java
// public interface Function2<T, R, S> extends Function {
//     S 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/test/java/xiaofei/library/shelly/domino/Test07.java
import org.junit.Test;
import xiaofei.library.shelly.Shelly;
import xiaofei.library.shelly.function.Action1;
import xiaofei.library.shelly.function.Function1;
import xiaofei.library.shelly.function.Function2;
import xiaofei.library.shelly.function.TargetAction1;

    public void testMap() {
        A a1 = new A(1), a2 = new B(2);
        Shelly.register(a1);
        Shelly.register(a2);
        Shelly.<A>createDomino(2)
                .perform(new Action1<A>() {
                    @Override
                    public void call(A input) {
                        System.out.println("1: " + input.getX());
                    }
                })
                .map(A.class, new Function2<A, A, String>() {
                    @Override
                    public String call(A input1, A input2) {
                        return "" + input1.getX() + " " + input2.getX();
                    }
                })
                .perform(new Action1<String>() {
                    @Override
                    public void call(String input) {
                        System.out.println("2: " + input);
                    }
                })
                .commit();
        Shelly.playDomino(2, a1, a2);
    }

    @Test
    public void testBackgroundQueue() {
        Shelly.<String>createDomino(3)
                .backgroundQueue()