package com.jscape.inet.proxy;

import com.jscape.util.net.TransportAddress;
import com.jscape.util.net.connection.SyncRawConnection;

import java.io.IOException;

/**
 * @author Alex Usun
 */
public interface Proxy {

    Proxy NULL = (connection, address, username, password) -> connection;
    
    SyncRawConnection openConnection(SyncRawConnection connection, TransportAddress address, String username, String password)
            throws IOException;

    class OperationException
            extends IOException {

        private static final long serialVersionUID = 6180410779599980205L;

        public OperationException() {
        }

        public OperationException(String message) {
            super(message);
        }

        public OperationException(String message, Throwable cause) {
            super(message, cause);
        }

        public OperationException(Throwable cause) {
            super(cause.getMessage() != null ? cause.getMessage() : cause.toString(), cause);
        }
    }
}
