package com.uxxu.konashi.lib.action;

import android.bluetooth.BluetoothGattCharacteristic;
import android.bluetooth.BluetoothGattService;

import com.uxxu.konashi.lib.KonashiErrorType;

import java.util.UUID;

import info.izumin.android.bletia.BleErrorType;
import info.izumin.android.bletia.BletiaException;
import info.izumin.android.bletia.action.WriteCharacteristicAction;
import info.izumin.android.bletia.wrapper.BluetoothGattWrapper;

/**
 * Created by izumin on 9/17/15.
 */
public abstract class KonashiWriteCharacteristicAction extends WriteCharacteristicAction {

    protected KonashiWriteCharacteristicAction(BluetoothGattCharacteristic characteristic) {
        super(characteristic);
    }

    protected KonashiWriteCharacteristicAction(BluetoothGattService service, UUID uuid) {
        this(service.getCharacteristic(uuid));
    }

    @Override
    public void execute(BluetoothGattWrapper gattWrapper) {
        KonashiErrorType errorType = validate();
        if (errorType == KonashiErrorType.NO_ERROR) {
            setValue();
            super.execute(gattWrapper);
        } else {
            rejectIfParamsAreInvalid(errorType);
        }
    }

    protected void rejectIfParamsAreInvalid(KonashiErrorType errorType) {
        getDeferred().reject(new BletiaException(errorType, getCharacteristic()));
    }

    protected abstract void setValue();
    protected abstract KonashiErrorType validate();
}

@@ -252,16 +252,67 @@
 orType;%0A
+import info.izumin.android.bletia.BletiaErrorType;%0A
 import i
@@ -977,23 +977,22 @@
         
-Konashi
+Bletia
 ErrorTyp
@@ -1262,23 +1262,22 @@
 Invalid(
-Konashi
+Bletia
 ErrorTyp
@@ -1444,23 +1444,22 @@
 bstract 
-Konashi
+Bletia
 ErrorTyp

Change using ErrorType