// Path: encoder/src/main/java/ru/bullyboo/encoder/callbacks/EncodeCallback.java
// public interface EncodeCallback {
// 
//     void onSuccess(String result);
// 
//     void onFailure(Throwable e);
// }
// 
// Path: encoder/src/main/java/ru/bullyboo/encoder/threads/BaseThread.java
// public abstract class BaseThread<T> extends Thread implements RunnableFuture<T> {
// 
//     private EncodeAction encodeAction;
// 
//     private ThreadCallback threadCallback;
// 
//     private volatile T result;
// 
//     public interface EncodeAction<T>{
//         T action();
//     }
// 
//     public interface ThreadCallback<T>{
//         void onFinish(T parametr);
// 
//         void onFailed(Throwable e);
//     }
// 
//     public BaseThread(EncodeAction<T> encodeAction, ThreadCallback<T> threadCallback) {
//         super();
//         this.encodeAction = encodeAction;
//         this.threadCallback = threadCallback;
//     }
// 
//     @Override
//     public void run(){
//         super.run();
//         result = (T) encodeAction.action();
// 
//         interrupt();
//     }
// 
//     @Override
//     public void interrupt() {
//         super.interrupt();
//         try {
//             threadCallback.onFinish(get());
//         } catch (Exception e) {
//             threadCallback.onFailed(e);
//         }
//     }
// 
//     @Override
//     public boolean cancel(boolean mayInterruptIfRunning) {
//         if(mayInterruptIfRunning){
//             interrupt();
//         }
//         return mayInterruptIfRunning;
//     }
// 
//     @Override
//     public boolean isCancelled() {
//         return interrupted();
//     }
// 
//     @Override
//     public boolean isDone() {
//         if(result != null){
//             return true;
//         }
//         return false;
//     }
// 
//     @Override
//     public T get() throws InterruptedException, ExecutionException {
//         return result;
//     }
// 
//     @Override
//     public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
//         return result;
//     }
// }
// 
// Path: encoder/src/main/java/ru/bullyboo/encoder/threads/EncodingThread.java
// public class EncodingThread extends BaseThread<String>{
// 
//     public EncodingThread(EncodeAction<String> encodeAction, ThreadCallback<String> threadCallback) {
//         super(encodeAction, threadCallback);
//     }
// }


import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import ru.bullyboo.encoder.callbacks.EncodeCallback;
import ru.bullyboo.encoder.threads.BaseThread;
import ru.bullyboo.encoder.threads.EncodingThread;
            e.printStackTrace();
        }
        return (B) this;
    }

    /**
     * Set the callback
     */
    public BaseBuilder encryptCallBack(EncodeCallback callback){
        this.callback = callback;
        return this;
    }

    /**
     * Start of asynchronous encrypting
    */
    public void encryptAsync(){
        if(hasEnoughData()){
            BaseThread.EncodeAction action = new BaseThread.EncodeAction() {
                @Override
                public String action() {
                    try {
                        return encryption();
                    } catch (Exception e) {
                        callback.onFailure(e);
                    }
                    return null;
                }
            };

// Path: encoder/src/main/java/ru/bullyboo/encoder/callbacks/EncodeCallback.java
// public interface EncodeCallback {
// 
//     void onSuccess(String result);
// 
//     void onFailure(Throwable e);
// }
// 
// Path: encoder/src/main/java/ru/bullyboo/encoder/threads/BaseThread.java
// public abstract class BaseThread<T> extends Thread implements RunnableFuture<T> {
// 
//     private EncodeAction encodeAction;
// 
//     private ThreadCallback threadCallback;
// 
//     private volatile T result;
// 
//     public interface EncodeAction<T>{
//         T action();
//     }
// 
//     public interface ThreadCallback<T>{
//         void onFinish(T parametr);
// 
//         void onFailed(Throwable e);
//     }
// 
//     public BaseThread(EncodeAction<T> encodeAction, ThreadCallback<T> threadCallback) {
//         super();
//         this.encodeAction = encodeAction;
//         this.threadCallback = threadCallback;
//     }
// 
//     @Override
//     public void run(){
//         super.run();
//         result = (T) encodeAction.action();
// 
//         interrupt();
//     }
// 
//     @Override
//     public void interrupt() {
//         super.interrupt();
//         try {
//             threadCallback.onFinish(get());
//         } catch (Exception e) {
//             threadCallback.onFailed(e);
//         }
//     }
// 
//     @Override
//     public boolean cancel(boolean mayInterruptIfRunning) {
//         if(mayInterruptIfRunning){
//             interrupt();
//         }
//         return mayInterruptIfRunning;
//     }
// 
//     @Override
//     public boolean isCancelled() {
//         return interrupted();
//     }
// 
//     @Override
//     public boolean isDone() {
//         if(result != null){
//             return true;
//         }
//         return false;
//     }
// 
//     @Override
//     public T get() throws InterruptedException, ExecutionException {
//         return result;
//     }
// 
//     @Override
//     public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
//         return result;
//     }
// }
// 
// Path: encoder/src/main/java/ru/bullyboo/encoder/threads/EncodingThread.java
// public class EncodingThread extends BaseThread<String>{
// 
//     public EncodingThread(EncodeAction<String> encodeAction, ThreadCallback<String> threadCallback) {
//         super(encodeAction, threadCallback);
//     }
// }


// Path: encoder/src/main/java/ru/bullyboo/encoder/builders/BaseBuilder.java
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import ru.bullyboo.encoder.callbacks.EncodeCallback;
import ru.bullyboo.encoder.threads.BaseThread;
import ru.bullyboo.encoder.threads.EncodingThread;

            e.printStackTrace();
        }
        return (B) this;
    }

    /**
     * Set the callback
     */
    public BaseBuilder encryptCallBack(EncodeCallback callback){
        this.callback = callback;
        return this;
    }

    /**
     * Start of asynchronous encrypting
    */
    public void encryptAsync(){
        if(hasEnoughData()){
            BaseThread.EncodeAction action = new BaseThread.EncodeAction() {
                @Override
                public String action() {
                    try {
                        return encryption();
                    } catch (Exception e) {
                        callback.onFailure(e);
                    }
                    return null;
                }
            };

            new EncodingThread(action, new BaseThread.ThreadCallback<String>() {