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().

  • Method Details

    • cache

      Returns the cache used to store pending commands.
      Specified by:
      cache in interface ConfirmationConfiguration<C>
      Returns:
      the cache
    • noPendingCommandNotifier

      public @NonNull Consumer<C> noPendingCommandNotifier()
      Returns a consumer that gets invoked when a sender tries to invoke the confirmation handler without having any pending commands.
      Specified by:
      noPendingCommandNotifier in interface ConfirmationConfiguration<C>
      Returns:
      notifier for no pending commands
    • confirmationRequiredNotifier

      public @NonNull BiConsumer<C,ConfirmationContext<C>> confirmationRequiredNotifier()
      Returns a consumer that gets invoked when a command requires confirmation.
      Specified by:
      confirmationRequiredNotifier in interface ConfirmationConfiguration<C>
      Returns:
      notifier for commands that require confirmation
    • bypassConfirmation

      public @NonNull Predicate<CommandContext<C>> bypassConfirmation()
      Returns a predicate that determines whether the CommandContext should bypass the confirmation requirement.

      The default implementation always returns false

      Specified by:
      bypassConfirmation in interface ConfirmationConfiguration<C>
      Returns:
      predicate that determines whether confirmation should be skipped
    • expiration

      public @Nullable Duration expiration()
      Returns the time to keep the pending commands for. This can be set to null to not enforce an expiration time.

      It is recommended to configure the cache() to match this value.

      The default value is null.

      Specified by:
      expiration in interface ConfirmationConfiguration<C>
      Returns:
      the expiration duration
    • withCache

      Copy the current immutable object by setting a value for the cache attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for cache
      Returns:
      A modified copy of the this object
    • withNoPendingCommandNotifier

      public final ImmutableConfirmationConfiguration<C> withNoPendingCommandNotifier(@NonNull Consumer<C> value)
      Copy the current immutable object by setting a value for the noPendingCommandNotifier attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for noPendingCommandNotifier
      Returns:
      A modified copy of the this object
    • withConfirmationRequiredNotifier

      public final ImmutableConfirmationConfiguration<C> withConfirmationRequiredNotifier(@NonNull BiConsumer<C,ConfirmationContext<C>> value)
      Copy the current immutable object by setting a value for the confirmationRequiredNotifier attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for confirmationRequiredNotifier
      Returns:
      A modified copy of the this object
    • withBypassConfirmation

      public final ImmutableConfirmationConfiguration<C> withBypassConfirmation(@NonNull Predicate<CommandContext<C>> value)
      Copy the current immutable object by setting a value for the bypassConfirmation attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for bypassConfirmation
      Returns:
      A modified copy of the this object
    • withExpiration

      public final ImmutableConfirmationConfiguration<C> withExpiration(@Nullable Duration value)
      Copy the current immutable object by setting a value for the expiration attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for expiration (can be null)
      Returns:
      A modified copy of the this object
    • equals

      public boolean equals(Object another)
      This instance is equal to all instances of ImmutableConfirmationConfiguration that have equal attribute values.
      Overrides:
      equals in class Object
      Returns:
      true if this is equal to another instance
    • hashCode

      public int hashCode()
      Computes a hash code from attributes: cache, noPendingCommandNotifier, confirmationRequiredNotifier, bypassConfirmation, expiration.
      Overrides:
      hashCode in class Object
      Returns:
      hashCode value
    • toString

      public String toString()
      Prints the immutable value ConfirmationConfiguration with attribute values.
      Overrides:
      toString in class Object
      Returns:
      A string representation of the value
    • 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 immutable ConfirmationConfiguration instance.
      Type Parameters:
      C - generic parameter C
      Parameters:
      cache - The value for the cache attribute
      noPendingCommandNotifier - The value for the noPendingCommandNotifier attribute
      confirmationRequiredNotifier - The value for the confirmationRequiredNotifier attribute
      bypassConfirmation - The value for the bypassConfirmation attribute
      expiration - The value for the expiration attribute
      Returns:
      An immutable ConfirmationConfiguration instance
    • copyOf

      public static <C> ImmutableConfirmationConfiguration<C> copyOf(ConfirmationConfiguration<C> instance)
      Creates an immutable copy of a ConfirmationConfiguration value. 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 for ImmutableConfirmationConfiguration.
       ImmutableConfirmationConfiguration.&lt;C&gt;builder()
          .cache(org.incendo.cloud.processors.cache.@org.checkerframework.checker.nullness.qual.NonNull CloudCache&lt;C, org.incendo.cloud.processors.confirmation.ConfirmationContext&lt;C&gt;&gt;) // required cache
          .noPendingCommandNotifier(function.@org.checkerframework.checker.nullness.qual.NonNull Consumer&lt;C&gt;) // required noPendingCommandNotifier
          .confirmationRequiredNotifier(function.@org.checkerframework.checker.nullness.qual.NonNull BiConsumer&lt;C, org.incendo.cloud.processors.confirmation.ConfirmationContext&lt;C&gt;&gt;) // required confirmationRequiredNotifier
          .bypassConfirmation(function.@org.checkerframework.checker.nullness.qual.NonNull Predicate&lt;org.incendo.cloud.context.CommandContext&lt;C&gt;&gt;) // optional bypassConfirmation
          .expiration(java.time.@org.checkerframework.checker.nullness.qual.Nullable Duration | null) // nullable expiration
          .build();
       
      Type Parameters:
      C - generic parameter C
      Returns:
      A new ImmutableConfirmationConfiguration builder