// 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/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/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.concurrentutils.ObjectCanary;
import xiaofei.library.concurrentutils.util.Action;
import xiaofei.library.concurrentutils.util.Condition;
import xiaofei.library.concurrentutils.util.Function;
import xiaofei.library.shelly.function.Function1;
import xiaofei.library.shelly.function.Function2;
import xiaofei.library.shelly.task.Task;
import xiaofei.library.shelly.tuple.Triple;
/**
 *
 * Copyright 2016 Xiaofei
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

package xiaofei.library.shelly.util;



/**
 * Created by Xiaofei on 16/6/30.
 */
public class TaskFunction<T, R1, R2, U1, U2>
        implements Function1<T, Triple<Boolean, R2, U2>>, Task.TaskListener<R1, U1> {

    private Task<T, R1, U1> mTask;

// 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/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/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/main/java/xiaofei/library/shelly/util/TaskFunction.java
import xiaofei.library.concurrentutils.ObjectCanary;
import xiaofei.library.concurrentutils.util.Action;
import xiaofei.library.concurrentutils.util.Condition;
import xiaofei.library.concurrentutils.util.Function;
import xiaofei.library.shelly.function.Function1;
import xiaofei.library.shelly.function.Function2;
import xiaofei.library.shelly.task.Task;
import xiaofei.library.shelly.tuple.Triple;

/**
 *
 * Copyright 2016 Xiaofei
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

package xiaofei.library.shelly.util;



/**
 * Created by Xiaofei on 16/6/30.
 */
public class TaskFunction<T, R1, R2, U1, U2>
        implements Function1<T, Triple<Boolean, R2, U2>>, Task.TaskListener<R1, U1> {

    private Task<T, R1, U1> mTask;

    private Function2<T, R1, R2> mFunc1;