Package org.johnnei.javatorrent.network
Class ConnectionDegradation.Builder
- java.lang.Object
-
- org.johnnei.javatorrent.network.ConnectionDegradation.Builder
-
- Enclosing class:
- ConnectionDegradation
public static class ConnectionDegradation.Builder extends Object
A builder pattern styled class to createConnectionDegradationinstances.
-
-
Constructor Summary
Constructors Constructor Description Builder()Creates a new builder without configured defaults.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ConnectionDegradationbuild()<T extends ISocket>
ConnectionDegradation.BuilderregisterConnectionType(Class<T> socketType, Supplier<T> supplier)Registers a new supported connection type.<T extends ISocket>
ConnectionDegradation.BuilderregisterConnectionType(Class<T> socketType, Supplier<T> supplier, Class<? extends ISocket> fallbackType)Registers a new supported connection type.<T extends ISocket>
ConnectionDegradation.BuilderregisterDefaultConnectionType(Class<T> socketType, Supplier<T> supplier)Registers a new supported connection type.<T extends ISocket>
ConnectionDegradation.BuilderregisterDefaultConnectionType(Class<T> socketType, Supplier<T> supplier, Class<? extends ISocket> fallbackType)Registers a new supported connection type.
-
-
-
Method Detail
-
registerDefaultConnectionType
public <T extends ISocket> ConnectionDegradation.Builder registerDefaultConnectionType(Class<T> socketType, Supplier<T> supplier)
Registers a new supported connection type. This type will be used first to connect with peers. When the connection fails there will be no further attempts to connect. This will override any previously configured default socket types.- Type Parameters:
T- The type of the socket- Parameters:
socketType- The type of the socket.supplier- TheSuppliermethod which creates new unconnected socket instances- Returns:
- The builder with updated configuration.
- See Also:
registerDefaultConnectionType(Class, Supplier, Class)
-
registerDefaultConnectionType
public <T extends ISocket> ConnectionDegradation.Builder registerDefaultConnectionType(Class<T> socketType, Supplier<T> supplier, Class<? extends ISocket> fallbackType)
Registers a new supported connection type. This type will be used first to connect with peers. The given fallback will be the used to connect when this type fails to connect to the peer. This will override any previously configured default socket types.- Type Parameters:
T- The type of the socket- Parameters:
socketType- The type of the socket.supplier- TheSuppliermethod which creates new unconnected socket instancesfallbackType- The socket type to use whensocketTypeconnection fails.- Returns:
- The builder with updated configuration.
- See Also:
registerConnectionType(Class, Supplier, Class)
-
registerConnectionType
public <T extends ISocket> ConnectionDegradation.Builder registerConnectionType(Class<T> socketType, Supplier<T> supplier)
Registers a new supported connection type. When the connection fails there will be no further attempts to connect. socket types.- Type Parameters:
T- The type of the socket- Parameters:
socketType- The type of the socket.supplier- TheSuppliermethod which creates new unconnected socket instances- Returns:
- The builder with updated configuration.
- See Also:
registerDefaultConnectionType(Class, Supplier)
-
registerConnectionType
public <T extends ISocket> ConnectionDegradation.Builder registerConnectionType(Class<T> socketType, Supplier<T> supplier, Class<? extends ISocket> fallbackType)
Registers a new supported connection type. The given fallback will be the used to connect when this type fails to connect to the peer. This will override any previously configured default socket types.- Type Parameters:
T- The type of the socket- Parameters:
socketType- The type of the socket.supplier- TheSuppliermethod which creates new unconnected socket instancesfallbackType- The socket type to use whensocketTypeconnection fails.- Returns:
- The builder with updated configuration.
- See Also:
registerDefaultConnectionType(Class, Supplier, Class)
-
build
public ConnectionDegradation build()
- Returns:
- The newly created configured
ConnectionDegradationinstance.
-
-