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
Modifier and TypeClassDescriptionstatic enum
The 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 DisconnectBehavior
Create aDisconnectBehavior
that instructs a client to retry in a graceful manner, with an optional cause.static DisconnectBehavior
retryAbruptly
(Throwable cause) Create aDisconnectBehavior
that instructs a client to retry abruptly, with an optional cause.static DisconnectBehavior
Create aDisconnectBehavior
that instructs a client to stop in a graceful manner, with an optional cause.static DisconnectBehavior
stopAbruptly
(Throwable cause) Create aDisconnectBehavior
that instructs a client to stop abruptly, with an optional cause.toString()
-
Method Details
-
retry
Create aDisconnectBehavior
that instructs a client to retry in a graceful manner, with an optional cause.- Parameters:
cause
- optionally, aThrowable
that triggered this close intent- Returns:
- a
DisconnectBehavior
that will gracefully attempt to retry
-
stop
Create aDisconnectBehavior
that instructs a client to stop in a graceful manner, with an optional cause.- Parameters:
cause
- optionally, aThrowable
that triggered this close intent- Returns:
- a
DisconnectBehavior
that will gracefully stop and release resources
-
retryAbruptly
Create aDisconnectBehavior
that instructs a client to retry abruptly, with an optional cause.- Parameters:
cause
- optionally, aThrowable
that triggered this close intent- Returns:
- a
DisconnectBehavior
that will abruptly close before attempting to retry
-
stopAbruptly
Create aDisconnectBehavior
that instructs a client to stop abruptly, with an optional cause.- Parameters:
cause
- optionally, aThrowable
that triggered this close intent- Returns:
- a
DisconnectBehavior
that will abruptly stop and release resources
-
getAction
Returns the action to perform while closing a resource.- Returns:
- an
DisconnectBehavior.Action
to perform upon closing
-
getCause
Returns the cause that triggered this close intent.- Returns:
- a
Throwable
representing the cause that triggers an action
-
toString
-