Class ConfirmationManager<C>
java.lang.Object
org.incendo.cloud.processors.confirmation.ConfirmationManager<C>
- Type Parameters:
C- command sender type
- All Implemented Interfaces:
Command.Builder.Applicable<C>
@API(status=STABLE,
since="1.0.0")
public final class ConfirmationManager<C>
extends Object
implements Command.Builder.Applicable<C>
Manager for the confirmation system.
- Since:
- 1.0.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionCommandMetakey that indicates that the command requires a confirmation to be executed. -
Method Summary
Modifier and TypeMethodDescriptionapplyToCommandBuilder(@NonNull Command.Builder<C> builder) Applies theMETA_CONFIRMATION_REQUIREDmeta key to the givenbuilder.Returns the configuration for this manager.static <C> @NonNull ConfirmationManager<C>confirmationManager(@NonNull Function<@NonNull ImmutableConfirmationConfiguration.CacheBuildStage<C>, @NonNull ImmutableConfirmationConfiguration.BuildFinal<C>> configuration) Creates a new confirmation manager using the givenconfiguration.static <C> @NonNull ConfirmationManager<C>confirmationManager(@NonNull ConfirmationConfiguration<C> configuration) Creates a new confirmation manager using the givenconfiguration.Returns aCommandExecutionHandlerthat will execute the pending command for the command sender, or invoke theConfirmationConfiguration.noPendingCommandNotifier().Returns aCommandPostprocessorthat will prevent commands from executing if they are marked as needing confirmation.popPending(@NonNull C sender) Removes theConfirmationContextstored for the givensenderand returns it.
-
Field Details
-
META_CONFIRMATION_REQUIRED
CommandMetakey that indicates that the command requires a confirmation to be executed.
-
-
Method Details
-
confirmationManager
public static <C> @NonNull ConfirmationManager<C> confirmationManager(@NonNull ConfirmationConfiguration<C> configuration) Creates a new confirmation manager using the givenconfiguration.- Type Parameters:
C- command sender type- Parameters:
configuration- configuration for the confirmation manager- Returns:
- the created manager
-
confirmationManager
public static <C> @NonNull ConfirmationManager<C> confirmationManager(@NonNull Function<@NonNull ImmutableConfirmationConfiguration.CacheBuildStage<C>, @NonNull ImmutableConfirmationConfiguration.BuildFinal<C>> configuration) Creates a new confirmation manager using the givenconfiguration.- Type Parameters:
C- command sender type- Parameters:
configuration- configuration for the confirmation manager- Returns:
- the created manager
-
configuration
Returns the configuration for this manager.- Returns:
- the configuration
-
applyToCommandBuilder
Applies theMETA_CONFIRMATION_REQUIREDmeta key to the givenbuilder.- Specified by:
applyToCommandBuilderin interfaceCommand.Builder.Applicable<C>- Parameters:
builder- builder to decorate- Returns:
- the decorated builder
-
createExecutionHandler
Returns aCommandExecutionHandlerthat will execute the pending command for the command sender, or invoke theConfirmationConfiguration.noPendingCommandNotifier().- Returns:
- confirmation execution handler
-
createPostprocessor
Returns aCommandPostprocessorthat will prevent commands from executing if they are marked as needing confirmation.- Returns:
- confirmation postprocessor
-
popPending
Removes theConfirmationContextstored for the givensenderand returns it.- Parameters:
sender- command sender- Returns:
- optional containing the value if it exists and has not yet expired
-