Class ImmutableCooldownConfiguration<C>

java.lang.Object
org.incendo.cloud.processors.cooldown.ImmutableCooldownConfiguration<C>
All Implemented Interfaces:
CooldownConfiguration<C>

@Generated("org.immutables.processor.ProxyProcessor") public final class ImmutableCooldownConfiguration<C> extends Object implements CooldownConfiguration<C>
Immutable implementation of CooldownConfiguration.

Use the builder to create immutable instances: ImmutableCooldownConfiguration.builder(). Use the static factory method to create immutable instances: ImmutableCooldownConfiguration.of().

  • Method Details

    • repository

      public @NonNull CooldownRepository<C> repository()
      Returns the repository used to store cooldowns.
      Specified by:
      repository in interface CooldownConfiguration<C>
      Returns:
      the repository
    • activeCooldownListeners

      public @NonNull List<CooldownActiveListener<C>> activeCooldownListeners()
      Returns the active cooldown listeners.

      The active cooldown listeners are invoked when a cooldown is preventing a sender from executing a command.

      Specified by:
      activeCooldownListeners in interface CooldownConfiguration<C>
      Returns:
      active cooldown listeners
    • creationListeners

      public @NonNull List<CooldownCreationListener<C>> creationListeners()
      Returns the creation listeners.

      The creation listeners are invoked when a new cooldown is created.

      Specified by:
      creationListeners in interface CooldownConfiguration<C>
      Returns:
      creation listeners
    • bypassCooldown

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

      The default implementation always returns false

      Specified by:
      bypassCooldown in interface CooldownConfiguration<C>
      Returns:
      predicate that determines whether cooldowns should be skipped
    • clock

      public @NonNull Clock clock()
      Returns the clock used to calculate the current time.
      Specified by:
      clock in interface CooldownConfiguration<C>
      Returns:
      the clock
    • profileFactory

      public @NonNull CooldownProfileFactory profileFactory()
      Returns the factory that produces cooldown profiles.
      Specified by:
      profileFactory in interface CooldownConfiguration<C>
      Returns:
      cooldown profile factory
    • fallbackGroup

      public @NonNull Function<Command<C>,CooldownGroup> fallbackGroup()
      Returns the function that determines the fallback CooldownGroup in case no group has been provided to the Cooldown.
      Specified by:
      fallbackGroup in interface CooldownConfiguration<C>
      Returns:
      the fallback group function
    • withRepository

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

      @SafeVarargs public final ImmutableCooldownConfiguration<C> withActiveCooldownListeners(CooldownActiveListener<C>... elements)
      Copy the current immutable object with elements that replace the content of activeCooldownListeners.
      Parameters:
      elements - The elements to set
      Returns:
      A modified copy of this object
    • withActiveCooldownListeners

      public final ImmutableCooldownConfiguration<C> withActiveCooldownListeners(Iterable<? extends CooldownActiveListener<C>> elements)
      Copy the current immutable object with elements that replace the content of activeCooldownListeners. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      elements - An iterable of activeCooldownListeners elements to set
      Returns:
      A modified copy of this object
    • withCreationListeners

      @SafeVarargs public final ImmutableCooldownConfiguration<C> withCreationListeners(CooldownCreationListener<C>... elements)
      Copy the current immutable object with elements that replace the content of creationListeners.
      Parameters:
      elements - The elements to set
      Returns:
      A modified copy of this object
    • withCreationListeners

      public final ImmutableCooldownConfiguration<C> withCreationListeners(Iterable<? extends CooldownCreationListener<C>> elements)
      Copy the current immutable object with elements that replace the content of creationListeners. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      elements - An iterable of creationListeners elements to set
      Returns:
      A modified copy of this object
    • withBypassCooldown

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

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

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

      public final ImmutableCooldownConfiguration<C> withFallbackGroup(@NonNull Function<Command<C>,CooldownGroup> value)
      Copy the current immutable object by setting a value for the fallbackGroup attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for fallbackGroup
      Returns:
      A modified copy of the this object
    • equals

      public boolean equals(Object another)
      This instance is equal to all instances of ImmutableCooldownConfiguration 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: repository, activeCooldownListeners, creationListeners, bypassCooldown, clock, profileFactory, fallbackGroup.
      Overrides:
      hashCode in class Object
      Returns:
      hashCode value
    • toString

      public String toString()
      Prints the immutable value CooldownConfiguration with attribute values.
      Overrides:
      toString in class Object
      Returns:
      A string representation of the value
    • of

      public static <C> ImmutableCooldownConfiguration<C> of(@NonNull CooldownRepository<C> repository, @NonNull List<CooldownActiveListener<C>> activeCooldownListeners, @NonNull List<CooldownCreationListener<C>> creationListeners, @NonNull Predicate<CommandContext<C>> bypassCooldown, @NonNull Clock clock, @NonNull CooldownProfileFactory profileFactory, @NonNull Function<Command<C>,CooldownGroup> fallbackGroup)
      Construct a new immutable CooldownConfiguration instance.
      Type Parameters:
      C - generic parameter C
      Parameters:
      repository - The value for the repository attribute
      activeCooldownListeners - The value for the activeCooldownListeners attribute
      creationListeners - The value for the creationListeners attribute
      bypassCooldown - The value for the bypassCooldown attribute
      clock - The value for the clock attribute
      profileFactory - The value for the profileFactory attribute
      fallbackGroup - The value for the fallbackGroup attribute
      Returns:
      An immutable CooldownConfiguration instance
    • of

      public static <C> ImmutableCooldownConfiguration<C> of(@NonNull CooldownRepository<C> repository, Iterable<? extends CooldownActiveListener<C>> activeCooldownListeners, Iterable<? extends CooldownCreationListener<C>> creationListeners, @NonNull Predicate<CommandContext<C>> bypassCooldown, @NonNull Clock clock, @NonNull CooldownProfileFactory profileFactory, @NonNull Function<Command<C>,CooldownGroup> fallbackGroup)
      Construct a new immutable CooldownConfiguration instance.
      Type Parameters:
      C - generic parameter C
      Parameters:
      repository - The value for the repository attribute
      activeCooldownListeners - The value for the activeCooldownListeners attribute
      creationListeners - The value for the creationListeners attribute
      bypassCooldown - The value for the bypassCooldown attribute
      clock - The value for the clock attribute
      profileFactory - The value for the profileFactory attribute
      fallbackGroup - The value for the fallbackGroup attribute
      Returns:
      An immutable CooldownConfiguration instance
    • copyOf

      public static <C> ImmutableCooldownConfiguration<C> copyOf(CooldownConfiguration<C> instance)
      Creates an immutable copy of a CooldownConfiguration 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 CooldownConfiguration instance
    • builder

      Creates a builder for ImmutableCooldownConfiguration.
       ImmutableCooldownConfiguration.&lt;C&gt;builder()
          .repository(org.incendo.cloud.processors.cooldown.@org.checkerframework.checker.nullness.qual.NonNull CooldownRepository&lt;C&gt;) // required repository
          .addActiveCooldownListener|addAllActiveCooldownListeners(org.incendo.cloud.processors.cooldown.listener.CooldownActiveListener&lt;C&gt;) // activeCooldownListeners elements
          .addCreationListener|addAllCreationListeners(org.incendo.cloud.processors.cooldown.listener.CooldownCreationListener&lt;C&gt;) // creationListeners elements
          .bypassCooldown(function.@org.checkerframework.checker.nullness.qual.NonNull Predicate&lt;org.incendo.cloud.context.CommandContext&lt;C&gt;&gt;) // optional bypassCooldown
          .clock(java.time.@org.checkerframework.checker.nullness.qual.NonNull Clock) // optional clock
          .profileFactory(org.incendo.cloud.processors.cooldown.profile.@org.checkerframework.checker.nullness.qual.NonNull CooldownProfileFactory) // optional profileFactory
          .fallbackGroup(function.@org.checkerframework.checker.nullness.qual.NonNull Function&lt;org.incendo.cloud.Command&lt;C&gt;, org.incendo.cloud.processors.cooldown.CooldownGroup&gt;) // optional fallbackGroup
          .build();
       
      Type Parameters:
      C - generic parameter C
      Returns:
      A new ImmutableCooldownConfiguration builder