Class BucketTokenRegistry

java.lang.Object
dev.voidframework.bucket4j.BucketTokenRegistry

public final class BucketTokenRegistry extends Object
This is a factory to create Bucket instances which stores all Bucket instances in a registry.
Since:
1.9.0
  • Constructor Summary

    Constructors
    Constructor
    Description
    BucketTokenRegistry(com.typesafe.config.Config configuration)
    Build a new instance.
    BucketTokenRegistry(com.typesafe.config.Config configuration, Map<String,io.github.bucket4j.Bucket> initialBuckets)
    Build a new instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    io.github.bucket4j.Bucket
    bucket(String bucketName)
    Returns a managed Bucket or create a new one.
    io.github.bucket4j.Bucket
    bucket(String bucketName, String configurationPath)
    Returns a managed Bucket or create a new one from the given configuration path.
    io.github.bucket4j.Bucket
    bucketOrDie(String bucketName)
    Returns a managed Bucket or throw an exception if not exist.
    Map<String,io.github.bucket4j.Bucket>
    Returns all managed Bucket instances.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • BucketTokenRegistry

      public BucketTokenRegistry(com.typesafe.config.Config configuration)
      Build a new instance.
      Parameters:
      configuration - The application configuration
      Since:
      1.9.0
    • BucketTokenRegistry

      public BucketTokenRegistry(com.typesafe.config.Config configuration, Map<String,io.github.bucket4j.Bucket> initialBuckets)
      Build a new instance.
      Parameters:
      configuration - The application configuration
      initialBuckets - Initial Buckets
      Since:
      1.9.0
  • Method Details

    • bucketOrDie

      public io.github.bucket4j.Bucket bucketOrDie(String bucketName)
      Returns a managed Bucket or throw an exception if not exist.
      Parameters:
      bucketName - The name of the Bucket
      Returns:
      The Bucket
      Since:
      1.9.0
      See Also:
    • bucket

      public io.github.bucket4j.Bucket bucket(String bucketName)
      Returns a managed Bucket or create a new one. All setting keys to configure Bucket must exist into "voidframework.bucket4j.<bucketName>".
      Parameters:
      bucketName - The name of the Bucket
      Returns:
      The Bucket
      Since:
      1.9.0
    • bucket

      public io.github.bucket4j.Bucket bucket(String bucketName, String configurationPath)
      Returns a managed Bucket or create a new one from the given configuration path. If Bucket does not exist and "configurationPath" parameter is null, the exception BucketDoesNotExist will be thrown.
      Parameters:
      bucketName - The name of the Bucket
      configurationPath - The configuration path to use during Bucket creation process
      Returns:
      The Bucket
      Since:
      1.9.0
      See Also:
    • getAllBuckets

      public Map<String,io.github.bucket4j.Bucket> getAllBuckets()
      Returns all managed Bucket instances.
      Returns:
      All managed Bucket instances.
      Since:
      1.9.0