// Path: bletia/src/main/java/info/izumin/android/bletia/DeferredStrategy.java
// public class DeferredStrategy<T, E extends Throwable> implements ResolveStrategy<T, E, Promise<T, E, Void>> {
//     public static final String TAG = DeferredStrategy.class.getSimpleName();
// 
//     private final DeferredObject<T, E, Void> mDeferred;
// 
//     public DeferredStrategy() {
//         mDeferred = new DeferredObject<>();
//     }
// 
//     @Override
//     public void resolve(T value) {
//         mDeferred.resolve(value);
//     }
// 
//     @Override
//     public void reject(E throwable) {
//         mDeferred.reject(throwable);
//     }
// 
//     @Override
//     public Promise<T, E, Void> getResolver() {
//         return mDeferred.promise();
//     }
// }
// 
// Path: bletia-core/src/main/java/info/izumin/android/bletia/core/BletiaException.java
// public class BletiaException extends Exception {
// 
//     private final String mTag;
//     private final BletiaErrorType mType;
//     private AbstractAction mAction = null;
// 
//     public BletiaException(AbstractAction action, BletiaErrorType type) {
//         this(action, type.getName(), type);
//     }
// 
//     public BletiaException(AbstractAction action, String detailMessage, BletiaErrorType type) {
//         this(action.getClass().getSimpleName(), detailMessage, type);
//         mAction = action;
//     }
// 
//     public BletiaException(BleErrorType type) {
//         super();
//         mType = type;
//         mTag = getStackTrace()[0].getMethodName();
//     }
// 
//     public BletiaException(String tag, BletiaErrorType type) {
//         this(tag, type.getName(), type);
//     }
// 
//     public BletiaException(String tag, String detailMessage, BletiaErrorType type) {
//         super(detailMessage);
//         mType = type;
//         mTag = tag;
//     }
// 
//     @Override
//     public String getMessage() {
//         return "[" + mTag + "] " + super.getMessage();
//     }
// 
//     public String getTag() {
//         return mTag;
//     }
// 
//     public BletiaErrorType getType() {
//         return mType;
//     }
// 
//     public AbstractAction getAction() {
//         return mAction;
//     }
// }
// 
// Path: bletia-core/src/main/java/info/izumin/android/bletia/core/action/AbstractWriteCharacteristicAction.java
// public abstract class AbstractWriteCharacteristicAction<R> extends AbstractCharacteristicAction<R> {
// 
//     public AbstractWriteCharacteristicAction(BluetoothGattCharacteristic characteristic,
//                                              ResolveStrategy<BluetoothGattCharacteristic, BletiaException, R> resolveStrategy) {
//         super(characteristic, Type.WRITE_CHARACTERISTIC, resolveStrategy);
//     }
// 
//     @Override
//     public boolean execute(BluetoothGattWrapper gattWrapper) {
//         if (!gattWrapper.writeCharacteristic(getCharacteristic())) {
//             reject(new BletiaException(this, BleErrorType.OPERATION_INITIATED_FAILURE));
//             return false;
//         }
//         return true;
//     }
// }


import android.bluetooth.BluetoothGattCharacteristic;
import org.jdeferred.Promise;
import info.izumin.android.bletia.DeferredStrategy;
import info.izumin.android.bletia.core.BletiaException;
import info.izumin.android.bletia.core.action.AbstractWriteCharacteristicAction;
package info.izumin.android.bletia.action;




/**
 * Created by izumin on 9/15/15.
 */
public class WriteCharacteristicAction extends AbstractWriteCharacteristicAction<Promise<BluetoothGattCharacteristic, BletiaException, Void>> {

    public WriteCharacteristicAction(BluetoothGattCharacteristic characteristic) {
// Path: bletia/src/main/java/info/izumin/android/bletia/DeferredStrategy.java
// public class DeferredStrategy<T, E extends Throwable> implements ResolveStrategy<T, E, Promise<T, E, Void>> {
//     public static final String TAG = DeferredStrategy.class.getSimpleName();
// 
//     private final DeferredObject<T, E, Void> mDeferred;
// 
//     public DeferredStrategy() {
//         mDeferred = new DeferredObject<>();
//     }
// 
//     @Override
//     public void resolve(T value) {
//         mDeferred.resolve(value);
//     }
// 
//     @Override
//     public void reject(E throwable) {
//         mDeferred.reject(throwable);
//     }
// 
//     @Override
//     public Promise<T, E, Void> getResolver() {
//         return mDeferred.promise();
//     }
// }
// 
// Path: bletia-core/src/main/java/info/izumin/android/bletia/core/BletiaException.java
// public class BletiaException extends Exception {
// 
//     private final String mTag;
//     private final BletiaErrorType mType;
//     private AbstractAction mAction = null;
// 
//     public BletiaException(AbstractAction action, BletiaErrorType type) {
//         this(action, type.getName(), type);
//     }
// 
//     public BletiaException(AbstractAction action, String detailMessage, BletiaErrorType type) {
//         this(action.getClass().getSimpleName(), detailMessage, type);
//         mAction = action;
//     }
// 
//     public BletiaException(BleErrorType type) {
//         super();
//         mType = type;
//         mTag = getStackTrace()[0].getMethodName();
//     }
// 
//     public BletiaException(String tag, BletiaErrorType type) {
//         this(tag, type.getName(), type);
//     }
// 
//     public BletiaException(String tag, String detailMessage, BletiaErrorType type) {
//         super(detailMessage);
//         mType = type;
//         mTag = tag;
//     }
// 
//     @Override
//     public String getMessage() {
//         return "[" + mTag + "] " + super.getMessage();
//     }
// 
//     public String getTag() {
//         return mTag;
//     }
// 
//     public BletiaErrorType getType() {
//         return mType;
//     }
// 
//     public AbstractAction getAction() {
//         return mAction;
//     }
// }
// 
// Path: bletia-core/src/main/java/info/izumin/android/bletia/core/action/AbstractWriteCharacteristicAction.java
// public abstract class AbstractWriteCharacteristicAction<R> extends AbstractCharacteristicAction<R> {
// 
//     public AbstractWriteCharacteristicAction(BluetoothGattCharacteristic characteristic,
//                                              ResolveStrategy<BluetoothGattCharacteristic, BletiaException, R> resolveStrategy) {
//         super(characteristic, Type.WRITE_CHARACTERISTIC, resolveStrategy);
//     }
// 
//     @Override
//     public boolean execute(BluetoothGattWrapper gattWrapper) {
//         if (!gattWrapper.writeCharacteristic(getCharacteristic())) {
//             reject(new BletiaException(this, BleErrorType.OPERATION_INITIATED_FAILURE));
//             return false;
//         }
//         return true;
//     }
// }


// Path: bletia/src/main/java/info/izumin/android/bletia/action/WriteCharacteristicAction.java
import android.bluetooth.BluetoothGattCharacteristic;
import org.jdeferred.Promise;
import info.izumin.android.bletia.DeferredStrategy;
import info.izumin.android.bletia.core.BletiaException;
import info.izumin.android.bletia.core.action.AbstractWriteCharacteristicAction;

package info.izumin.android.bletia.action;




/**
 * Created by izumin on 9/15/15.
 */
public class WriteCharacteristicAction extends AbstractWriteCharacteristicAction<Promise<BluetoothGattCharacteristic, BletiaException, Void>> {

    public WriteCharacteristicAction(BluetoothGattCharacteristic characteristic) {
        super(characteristic, new DeferredStrategy<BluetoothGattCharacteristic, BletiaException>());