Package org.johnnei.javatorrent.network
Class ConnectionDegradation
- java.lang.Object
-
- org.johnnei.javatorrent.network.ConnectionDegradation
-
public class ConnectionDegradation extends Object
Controls the degradation of socket types ordered from most preferred to least preferred.- Author:
- johnn
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classConnectionDegradation.BuilderA builder pattern styled class to createConnectionDegradationinstances.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ISocketcreatePreferredSocket()Creates a new unconnected socket based on the most prefered connection type.Optional<ISocket>degradeSocket(ISocket socket)Degrades the given socket into the next typeStringtoString()
-
-
-
Method Detail
-
createPreferredSocket
public ISocket createPreferredSocket()
Creates a new unconnected socket based on the most prefered connection type.- Returns:
- An unconnected socket
-
degradeSocket
public Optional<ISocket> degradeSocket(ISocket socket)
Degrades the given socket into the next type- Parameters:
socket- The socket type to degrade- Returns:
- The degraded socket or
Optional.empty()when no degradation is possible
-
-