Class ImmutableConfirmationConfiguration<C>
java.lang.Object
org.incendo.cloud.processors.confirmation.ImmutableConfirmationConfiguration<C>
- All Implemented Interfaces:
ConfirmationConfiguration<C>
@Generated("org.immutables.processor.ProxyProcessor")
public final class ImmutableConfirmationConfiguration<C>
extends Object
implements ConfirmationConfiguration<C>
Immutable implementation of
ConfirmationConfiguration.
Use the builder to create immutable instances:
ImmutableConfirmationConfiguration.builder().
Use the static factory method to create immutable instances:
ImmutableConfirmationConfiguration.of().
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classBuilds instances of typeImmutableConfirmationConfiguration.static interfacestatic interfacestatic interfacestatic interface -
Method Summary
Modifier and TypeMethodDescriptionstatic <C> ImmutableConfirmationConfiguration.CacheBuildStage<C>builder()Creates a builder forImmutableConfirmationConfiguration.Returns a predicate that determines whether theCommandContextshould bypass the confirmation requirement.cache()Returns the cache used to store pending commands.Returns a consumer that gets invoked when a command requires confirmation.static <C> ImmutableConfirmationConfiguration<C>copyOf(ConfirmationConfiguration<C> instance) Creates an immutable copy of aConfirmationConfigurationvalue.booleanThis instance is equal to all instances ofImmutableConfirmationConfigurationthat have equal attribute values.Returns the time to keep the pending commands for.inthashCode()Computes a hash code from attributes:cache,noPendingCommandNotifier,confirmationRequiredNotifier,bypassConfirmation,expiration.Returns a consumer that gets invoked when a sender tries to invoke the confirmation handler without having any pending commands.static <C> ImmutableConfirmationConfiguration<C>of(@NonNull CloudCache<C, ConfirmationContext<C>> cache, @NonNull Consumer<C> noPendingCommandNotifier, @NonNull BiConsumer<C, ConfirmationContext<C>> confirmationRequiredNotifier, @NonNull Predicate<CommandContext<C>> bypassConfirmation, @Nullable Duration expiration) Construct a new immutableConfirmationConfigurationinstance.toString()Prints the immutable valueConfirmationConfigurationwith attribute values.Copy the current immutable object by setting a value for thebypassConfirmationattribute.withCache(@NonNull CloudCache<C, ConfirmationContext<C>> value) Copy the current immutable object by setting a value for thecacheattribute.Copy the current immutable object by setting a value for theconfirmationRequiredNotifierattribute.withExpiration(@Nullable Duration value) Copy the current immutable object by setting a value for theexpirationattribute.Copy the current immutable object by setting a value for thenoPendingCommandNotifierattribute.
-
Method Details
-
cache
Returns the cache used to store pending commands.- Specified by:
cachein interfaceConfirmationConfiguration<C>- Returns:
- the cache
-
noPendingCommandNotifier
Returns a consumer that gets invoked when a sender tries to invoke the confirmation handler without having any pending commands.- Specified by:
noPendingCommandNotifierin interfaceConfirmationConfiguration<C>- Returns:
- notifier for no pending commands
-
confirmationRequiredNotifier
Returns a consumer that gets invoked when a command requires confirmation.- Specified by:
confirmationRequiredNotifierin interfaceConfirmationConfiguration<C>- Returns:
- notifier for commands that require confirmation
-
bypassConfirmation
Returns a predicate that determines whether theCommandContextshould bypass the confirmation requirement.The default implementation always returns
false- Specified by:
bypassConfirmationin interfaceConfirmationConfiguration<C>- Returns:
- predicate that determines whether confirmation should be skipped
-
expiration
Returns the time to keep the pending commands for. This can be set tonullto not enforce an expiration time.It is recommended to configure the
cache()to match this value.The default value is
null.- Specified by:
expirationin interfaceConfirmationConfiguration<C>- Returns:
- the expiration duration
-
withCache
public final ImmutableConfirmationConfiguration<C> withCache(@NonNull CloudCache<C, ConfirmationContext<C>> value) Copy the current immutable object by setting a value for thecacheattribute. A shallow reference equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for cache- Returns:
- A modified copy of the
thisobject
-
withNoPendingCommandNotifier
public final ImmutableConfirmationConfiguration<C> withNoPendingCommandNotifier(@NonNull Consumer<C> value) Copy the current immutable object by setting a value for thenoPendingCommandNotifierattribute. A shallow reference equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for noPendingCommandNotifier- Returns:
- A modified copy of the
thisobject
-
withConfirmationRequiredNotifier
public final ImmutableConfirmationConfiguration<C> withConfirmationRequiredNotifier(@NonNull BiConsumer<C, ConfirmationContext<C>> value) Copy the current immutable object by setting a value for theconfirmationRequiredNotifierattribute. A shallow reference equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for confirmationRequiredNotifier- Returns:
- A modified copy of the
thisobject
-
withBypassConfirmation
public final ImmutableConfirmationConfiguration<C> withBypassConfirmation(@NonNull Predicate<CommandContext<C>> value) Copy the current immutable object by setting a value for thebypassConfirmationattribute. A shallow reference equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for bypassConfirmation- Returns:
- A modified copy of the
thisobject
-
withExpiration
Copy the current immutable object by setting a value for theexpirationattribute. A shallow reference equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for expiration (can benull)- Returns:
- A modified copy of the
thisobject
-
equals
This instance is equal to all instances ofImmutableConfirmationConfigurationthat have equal attribute values. -
hashCode
public int hashCode()Computes a hash code from attributes:cache,noPendingCommandNotifier,confirmationRequiredNotifier,bypassConfirmation,expiration. -
toString
Prints the immutable valueConfirmationConfigurationwith attribute values. -
of
public static <C> ImmutableConfirmationConfiguration<C> of(@NonNull CloudCache<C, ConfirmationContext<C>> cache, @NonNull Consumer<C> noPendingCommandNotifier, @NonNull BiConsumer<C, ConfirmationContext<C>> confirmationRequiredNotifier, @NonNull Predicate<CommandContext<C>> bypassConfirmation, @Nullable Duration expiration) Construct a new immutableConfirmationConfigurationinstance.- Type Parameters:
C- generic parameter C- Parameters:
cache- The value for thecacheattributenoPendingCommandNotifier- The value for thenoPendingCommandNotifierattributeconfirmationRequiredNotifier- The value for theconfirmationRequiredNotifierattributebypassConfirmation- The value for thebypassConfirmationattributeexpiration- The value for theexpirationattribute- Returns:
- An immutable ConfirmationConfiguration instance
-
copyOf
public static <C> ImmutableConfirmationConfiguration<C> copyOf(ConfirmationConfiguration<C> instance) Creates an immutable copy of aConfirmationConfigurationvalue. Uses accessors to get values to initialize the new immutable instance. If an instance is already immutable, it is returned as is.- Type Parameters:
C- generic parameter C- Parameters:
instance- The instance to copy- Returns:
- A copied immutable ConfirmationConfiguration instance
-
builder
Creates a builder forImmutableConfirmationConfiguration.ImmutableConfirmationConfiguration.<C>builder() .cache(org.incendo.cloud.processors.cache.@org.checkerframework.checker.nullness.qual.NonNull CloudCache<C, org.incendo.cloud.processors.confirmation.ConfirmationContext<C>>) // requiredcache.noPendingCommandNotifier(function.@org.checkerframework.checker.nullness.qual.NonNull Consumer<C>) // requirednoPendingCommandNotifier.confirmationRequiredNotifier(function.@org.checkerframework.checker.nullness.qual.NonNull BiConsumer<C, org.incendo.cloud.processors.confirmation.ConfirmationContext<C>>) // requiredconfirmationRequiredNotifier.bypassConfirmation(function.@org.checkerframework.checker.nullness.qual.NonNull Predicate<org.incendo.cloud.context.CommandContext<C>>) // optionalbypassConfirmation.expiration(java.time.@org.checkerframework.checker.nullness.qual.Nullable Duration | null) // nullableexpiration.build();- Type Parameters:
C- generic parameter C- Returns:
- A new ImmutableConfirmationConfiguration builder
-