Package discord4j.common.close
Class DisconnectBehavior
java.lang.Object
discord4j.common.close.DisconnectBehavior
Encapsulates a strategy to deal with the closing and release of a resource.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe action to trigger to close a resource. -
Method Summary
Modifier and TypeMethodDescriptionReturns the action to perform while closing a resource.getCause()Returns the cause that triggered this close intent.static DisconnectBehaviorCreate aDisconnectBehaviorthat instructs a client to retry in a graceful manner, with an optional cause.static DisconnectBehaviorretryAbruptly(Throwable cause) Create aDisconnectBehaviorthat instructs a client to retry abruptly, with an optional cause.static DisconnectBehaviorCreate aDisconnectBehaviorthat instructs a client to stop in a graceful manner, with an optional cause.static DisconnectBehaviorstopAbruptly(Throwable cause) Create aDisconnectBehaviorthat instructs a client to stop abruptly, with an optional cause.toString()
-
Method Details
-
retry
Create aDisconnectBehaviorthat instructs a client to retry in a graceful manner, with an optional cause.- Parameters:
cause- optionally, aThrowablethat triggered this close intent- Returns:
- a
DisconnectBehaviorthat will gracefully attempt to retry
-
stop
Create aDisconnectBehaviorthat instructs a client to stop in a graceful manner, with an optional cause.- Parameters:
cause- optionally, aThrowablethat triggered this close intent- Returns:
- a
DisconnectBehaviorthat will gracefully stop and release resources
-
retryAbruptly
Create aDisconnectBehaviorthat instructs a client to retry abruptly, with an optional cause.- Parameters:
cause- optionally, aThrowablethat triggered this close intent- Returns:
- a
DisconnectBehaviorthat will abruptly close before attempting to retry
-
stopAbruptly
Create aDisconnectBehaviorthat instructs a client to stop abruptly, with an optional cause.- Parameters:
cause- optionally, aThrowablethat triggered this close intent- Returns:
- a
DisconnectBehaviorthat will abruptly stop and release resources
-
getAction
Returns the action to perform while closing a resource.- Returns:
- an
DisconnectBehavior.Actionto perform upon closing
-
getCause
Returns the cause that triggered this close intent.- Returns:
- a
Throwablerepresenting the cause that triggers an action
-
toString
-