- java.lang.Object
-
- io.github.bucket4j.local.LocalBucketBuilder
-
public class LocalBucketBuilder extends Object
This builder creates in-memory buckets (LockFreeBucket).
-
-
Constructor Summary
Constructors Constructor Description LocalBucketBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description LocalBucketBuilderaddLimit(Bandwidth bandwidth)Adds limited bandwidth for all buckets which will be constructed by this builder.LocalBucketbuild()Constructs the bucket.LocalBucketBuilderwithCustomTimePrecision(TimeMeter customTimeMeter)SpecifiescustomTimeMetertime meter for buckets that will be created by this builder.LocalBucketBuilderwithMath(MathType mathType)Warnings: this is not a part of Public API.LocalBucketBuilderwithMillisecondPrecision()SpecifiesTimeMeter.SYSTEM_MILLISECONDSas time meter for buckets that will be created by this builder.LocalBucketBuilderwithNanosecondPrecision()SpecifiesTimeMeter.SYSTEM_NANOTIMEas time meter for buckets that will be created by this builder.LocalBucketBuilderwithSynchronizationStrategy(SynchronizationStrategy synchronizationStrategy)SpecifiessynchronizationStrategyfor buckets that will be created by this builder.
-
-
-
Method Detail
-
addLimit
public LocalBucketBuilder addLimit(Bandwidth bandwidth)
Adds limited bandwidth for all buckets which will be constructed by this builder.- Parameters:
bandwidth- limitation- Returns:
- this builder instance
-
withNanosecondPrecision
public LocalBucketBuilder withNanosecondPrecision()
SpecifiesTimeMeter.SYSTEM_NANOTIMEas time meter for buckets that will be created by this builder.- Returns:
- this builder instance
-
withMillisecondPrecision
public LocalBucketBuilder withMillisecondPrecision()
SpecifiesTimeMeter.SYSTEM_MILLISECONDSas time meter for buckets that will be created by this builder.- Returns:
- this builder instance
-
withCustomTimePrecision
public LocalBucketBuilder withCustomTimePrecision(TimeMeter customTimeMeter)
SpecifiescustomTimeMetertime meter for buckets that will be created by this builder.- Parameters:
customTimeMeter- object which will measure time.- Returns:
- this builder instance
-
withSynchronizationStrategy
public LocalBucketBuilder withSynchronizationStrategy(SynchronizationStrategy synchronizationStrategy)
SpecifiessynchronizationStrategyfor buckets that will be created by this builder.- Parameters:
synchronizationStrategy- the strategy of synchronization which need to be applied to prevent data-races in multi-threading usage scenario.- Returns:
- this builder instance
-
withMath
public LocalBucketBuilder withMath(MathType mathType)
Warnings: this is not a part of Public API. This method is intended to be used strongly by internal code and can be removed at any time without prior notice.- Parameters:
mathType-- Returns:
-
build
public LocalBucket build()
Constructs the bucket.- Returns:
- the new bucket
-
-