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().
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classBuilds instances of typeImmutableCooldownConfiguration.static interfacestatic interface -
Method Summary
Modifier and TypeMethodDescriptionReturns the active cooldown listeners.static <C> ImmutableCooldownConfiguration.RepositoryBuildStage<C>builder()Creates a builder forImmutableCooldownConfiguration.Returns a predicate that determines whether theCommandContextshould bypass the cooldown requirement.clock()Returns the clock used to calculate the current time.static <C> ImmutableCooldownConfiguration<C>copyOf(CooldownConfiguration<C> instance) Creates an immutable copy of aCooldownConfigurationvalue.Returns the creation listeners.booleanThis instance is equal to all instances ofImmutableCooldownConfigurationthat have equal attribute values.Returns the function that determines the fallbackCooldownGroupin case no group has been provided to theCooldown.inthashCode()Computes a hash code from attributes:repository,activeCooldownListeners,creationListeners,bypassCooldown,clock,profileFactory,fallbackGroup.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 immutableCooldownConfigurationinstance.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 immutableCooldownConfigurationinstance.Returns the factory that produces cooldown profiles.Returns the repository used to store cooldowns.toString()Prints the immutable valueCooldownConfigurationwith attribute values.final ImmutableCooldownConfiguration<C>withActiveCooldownListeners(Iterable<? extends CooldownActiveListener<C>> elements) Copy the current immutable object with elements that replace the content ofactiveCooldownListeners.final ImmutableCooldownConfiguration<C>withActiveCooldownListeners(CooldownActiveListener<C>... elements) Copy the current immutable object with elements that replace the content ofactiveCooldownListeners.final ImmutableCooldownConfiguration<C>withBypassCooldown(@NonNull Predicate<CommandContext<C>> value) Copy the current immutable object by setting a value for thebypassCooldownattribute.final ImmutableCooldownConfiguration<C>Copy the current immutable object by setting a value for theclockattribute.final ImmutableCooldownConfiguration<C>withCreationListeners(Iterable<? extends CooldownCreationListener<C>> elements) Copy the current immutable object with elements that replace the content ofcreationListeners.final ImmutableCooldownConfiguration<C>withCreationListeners(CooldownCreationListener<C>... elements) Copy the current immutable object with elements that replace the content ofcreationListeners.final ImmutableCooldownConfiguration<C>withFallbackGroup(@NonNull Function<Command<C>, CooldownGroup> value) Copy the current immutable object by setting a value for thefallbackGroupattribute.final ImmutableCooldownConfiguration<C>Copy the current immutable object by setting a value for theprofileFactoryattribute.final ImmutableCooldownConfiguration<C>withRepository(@NonNull CooldownRepository<C> value) Copy the current immutable object by setting a value for therepositoryattribute.
-
Method Details
-
repository
Returns the repository used to store cooldowns.- Specified by:
repositoryin interfaceCooldownConfiguration<C>- Returns:
- the repository
-
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:
activeCooldownListenersin interfaceCooldownConfiguration<C>- Returns:
- active cooldown listeners
-
creationListeners
Returns the creation listeners.The creation listeners are invoked when a new cooldown is created.
- Specified by:
creationListenersin interfaceCooldownConfiguration<C>- Returns:
- creation listeners
-
bypassCooldown
Returns a predicate that determines whether theCommandContextshould bypass the cooldown requirement.The default implementation always returns
false- Specified by:
bypassCooldownin interfaceCooldownConfiguration<C>- Returns:
- predicate that determines whether cooldowns should be skipped
-
clock
Returns the clock used to calculate the current time.- Specified by:
clockin interfaceCooldownConfiguration<C>- Returns:
- the clock
-
profileFactory
Returns the factory that produces cooldown profiles.- Specified by:
profileFactoryin interfaceCooldownConfiguration<C>- Returns:
- cooldown profile factory
-
fallbackGroup
Returns the function that determines the fallbackCooldownGroupin case no group has been provided to theCooldown.- Specified by:
fallbackGroupin interfaceCooldownConfiguration<C>- Returns:
- the fallback group function
-
withRepository
Copy the current immutable object by setting a value for therepositoryattribute. A shallow reference equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for repository- Returns:
- A modified copy of the
thisobject
-
withActiveCooldownListeners
@SafeVarargs public final ImmutableCooldownConfiguration<C> withActiveCooldownListeners(CooldownActiveListener<C>... elements) Copy the current immutable object with elements that replace the content ofactiveCooldownListeners.- Parameters:
elements- The elements to set- Returns:
- A modified copy of
thisobject
-
withActiveCooldownListeners
public final ImmutableCooldownConfiguration<C> withActiveCooldownListeners(Iterable<? extends CooldownActiveListener<C>> elements) Copy the current immutable object with elements that replace the content ofactiveCooldownListeners. A shallow reference equality check is used to prevent copying of the same value by returningthis.- Parameters:
elements- An iterable of activeCooldownListeners elements to set- Returns:
- A modified copy of
thisobject
-
withCreationListeners
@SafeVarargs public final ImmutableCooldownConfiguration<C> withCreationListeners(CooldownCreationListener<C>... elements) Copy the current immutable object with elements that replace the content ofcreationListeners.- Parameters:
elements- The elements to set- Returns:
- A modified copy of
thisobject
-
withCreationListeners
public final ImmutableCooldownConfiguration<C> withCreationListeners(Iterable<? extends CooldownCreationListener<C>> elements) Copy the current immutable object with elements that replace the content ofcreationListeners. A shallow reference equality check is used to prevent copying of the same value by returningthis.- Parameters:
elements- An iterable of creationListeners elements to set- Returns:
- A modified copy of
thisobject
-
withBypassCooldown
public final ImmutableCooldownConfiguration<C> withBypassCooldown(@NonNull Predicate<CommandContext<C>> value) Copy the current immutable object by setting a value for thebypassCooldownattribute. A shallow reference equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for bypassCooldown- Returns:
- A modified copy of the
thisobject
-
withClock
Copy the current immutable object by setting a value for theclockattribute. A shallow reference equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for clock- Returns:
- A modified copy of the
thisobject
-
withProfileFactory
public final ImmutableCooldownConfiguration<C> withProfileFactory(@NonNull CooldownProfileFactory value) Copy the current immutable object by setting a value for theprofileFactoryattribute. A shallow reference equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for profileFactory- Returns:
- A modified copy of the
thisobject
-
withFallbackGroup
public final ImmutableCooldownConfiguration<C> withFallbackGroup(@NonNull Function<Command<C>, CooldownGroup> value) Copy the current immutable object by setting a value for thefallbackGroupattribute. A shallow reference equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for fallbackGroup- Returns:
- A modified copy of the
thisobject
-
equals
This instance is equal to all instances ofImmutableCooldownConfigurationthat have equal attribute values. -
hashCode
public int hashCode()Computes a hash code from attributes:repository,activeCooldownListeners,creationListeners,bypassCooldown,clock,profileFactory,fallbackGroup. -
toString
Prints the immutable valueCooldownConfigurationwith attribute values. -
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 immutableCooldownConfigurationinstance.- Type Parameters:
C- generic parameter C- Parameters:
repository- The value for therepositoryattributeactiveCooldownListeners- The value for theactiveCooldownListenersattributecreationListeners- The value for thecreationListenersattributebypassCooldown- The value for thebypassCooldownattributeclock- The value for theclockattributeprofileFactory- The value for theprofileFactoryattributefallbackGroup- The value for thefallbackGroupattribute- 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 immutableCooldownConfigurationinstance.- Type Parameters:
C- generic parameter C- Parameters:
repository- The value for therepositoryattributeactiveCooldownListeners- The value for theactiveCooldownListenersattributecreationListeners- The value for thecreationListenersattributebypassCooldown- The value for thebypassCooldownattributeclock- The value for theclockattributeprofileFactory- The value for theprofileFactoryattributefallbackGroup- The value for thefallbackGroupattribute- Returns:
- An immutable CooldownConfiguration instance
-
copyOf
Creates an immutable copy of aCooldownConfigurationvalue. 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 forImmutableCooldownConfiguration.ImmutableCooldownConfiguration.<C>builder() .repository(org.incendo.cloud.processors.cooldown.@org.checkerframework.checker.nullness.qual.NonNull CooldownRepository<C>) // requiredrepository.addActiveCooldownListener|addAllActiveCooldownListeners(org.incendo.cloud.processors.cooldown.listener.CooldownActiveListener<C>) //activeCooldownListenerselements .addCreationListener|addAllCreationListeners(org.incendo.cloud.processors.cooldown.listener.CooldownCreationListener<C>) //creationListenerselements .bypassCooldown(function.@org.checkerframework.checker.nullness.qual.NonNull Predicate<org.incendo.cloud.context.CommandContext<C>>) // optionalbypassCooldown.clock(java.time.@org.checkerframework.checker.nullness.qual.NonNull Clock) // optionalclock.profileFactory(org.incendo.cloud.processors.cooldown.profile.@org.checkerframework.checker.nullness.qual.NonNull CooldownProfileFactory) // optionalprofileFactory.fallbackGroup(function.@org.checkerframework.checker.nullness.qual.NonNull Function<org.incendo.cloud.Command<C>, org.incendo.cloud.processors.cooldown.CooldownGroup>) // optionalfallbackGroup.build();- Type Parameters:
C- generic parameter C- Returns:
- A new ImmutableCooldownConfiguration builder
-