package org.craft.atom.nio.api;

import org.craft.atom.io.IoAcceptor;
import org.craft.atom.io.IoConnector;
import org.craft.atom.io.IoHandler;
import org.craft.atom.nio.NioTcpAcceptor;
import org.craft.atom.nio.NioTcpConnector;
import org.craft.atom.nio.spi.NioBufferSizePredictorFactory;
import org.craft.atom.nio.spi.NioChannelEventDispatcher;

/**
 * Nio Factory<br>
 * Use factory to create {@link NioTcpAcceptor} and {@link NioTcpConnector} instance.
 * 
 * @author mindwind
 * @version 1.0, Dec 17, 2013
 */
public class NioFactory {
	
	public static IoAcceptor newTcpAcceptor(IoHandler handler) {
		return new NioTcpAcceptor(handler);
	}
	
	public static IoAcceptor newTcpAcceptor(IoHandler handler, NioAcceptorConfig config) {
		return new NioTcpAcceptor(handler, config);
	}
	
	public static IoAcceptor newTcpAcceptor(IoHandler handler, NioAcceptorConfig config, NioChannelEventDispatcher dispatcher) {
		return new NioTcpAcceptor(handler, config, dispatcher);
	}
	
	public static IoAcceptor newTcpAcceptor(IoHandler handler, NioAcceptorConfig config, NioChannelEventDispatcher dispatcher, NioBufferSizePredictorFactory predictorFactory) {
		return new NioTcpAcceptor(handler, config, dispatcher, predictorFactory);
	}
	
	public static IoConnector newTcpConnector(IoHandler handler) {
		return new NioTcpConnector(handler);
	}
	
	public static IoConnector newTcpConnector(IoHandler handler, NioConnectorConfig config) {
		return new NioTcpConnector(handler, config);
	}
	
	public static IoConnector newTcpConnector(IoHandler handler, NioConnectorConfig config, NioChannelEventDispatcher dispatcher) {
		return new NioTcpConnector(handler, config, dispatcher);
	}
	
	public static IoConnector newTcpConnector(IoHandler handler, NioConnectorConfig config, NioChannelEventDispatcher dispatcher, NioBufferSizePredictorFactory predictorFactory) {
		return new NioTcpConnector(handler, config, dispatcher, predictorFactory);
	}
	
	public static NioTcpAcceptorBuilder newTcpAcceptorBuilder(IoHandler handler) {
		return new NioTcpAcceptorBuilder(handler);
	}
	
	public static NioTcpConnectorBuilder newTcpConnectorBuilder(IoHandler handler) {
		return new NioTcpConnectorBuilder(handler);
	}
}

@@ -602,36 +602,32 @@
 ) %7B%0A%09%09return new
- Nio
 TcpAcceptor(hand
@@ -613,32 +613,39 @@
 n newTcpAcceptor
+Builder
 (handler);%0A%09%7D%0A%09%0A
@@ -629,32 +629,40 @@
 Builder(handler)
+.build()
 ;%0A%09%7D%0A%09%0A%09public s
@@ -1303,36 +1303,32 @@
 ) %7B%0A%09%09return new
- Nio
 TcpConnector(han
@@ -1315,32 +1315,39 @@
  newTcpConnector
+Builder
 (handler);%0A%09%7D%0A%09%0A
@@ -1331,32 +1331,40 @@
 Builder(handler)
+.build()
 ;%0A%09%7D%0A%09%0A%09public s

improve - use builder for default factory method