Package discord4j.common.close
Class DisconnectBehavior
- java.lang.Object
-
- discord4j.common.close.DisconnectBehavior
-
public class DisconnectBehavior extends Object
Encapsulates a strategy to deal with the closing and release of a resource.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDisconnectBehavior.ActionThe action to trigger to close a resource.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description DisconnectBehavior.ActiongetAction()Returns the action to perform while closing a resource.ThrowablegetCause()Returns the cause that triggered this close intent.static DisconnectBehaviorretry(Throwable cause)Create 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 DisconnectBehaviorstop(Throwable cause)Create 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.StringtoString()
-
-
-
Method Detail
-
retry
public static DisconnectBehavior retry(@Nullable Throwable cause)
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
public static DisconnectBehavior stop(@Nullable Throwable cause)
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
public static DisconnectBehavior retryAbruptly(@Nullable Throwable cause)
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
public static DisconnectBehavior stopAbruptly(@Nullable Throwable cause)
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
public DisconnectBehavior.Action getAction()
Returns the action to perform while closing a resource.- Returns:
- an
DisconnectBehavior.Actionto perform upon closing
-
getCause
@Nullable public Throwable getCause()
Returns the cause that triggered this close intent.- Returns:
- a
Throwablerepresenting the cause that triggers an action
-
-