Class UniqueCodeGenerator.Builder
java.lang.Object
dev.getelements.elements.sdk.util.UniqueCodeGenerator.Builder
- Enclosing class:
UniqueCodeGenerator
Builder for the UniqueCodeGenerator.Configuration.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds the UniqueCodeGenerator with the specified configuration.Specifies rejection criteria for generated codes.rejectingOffensiveWords(OffensiveWordFilter offensiveWords) Rejects the offensive words provided by theOffensiveWordFilter.rejectingSubstrings(Predicate<String> rejection) Rejects generated codes that contain substrings matching the provided rejection predicate.withCandidates(CharSequence candidates) Specifies the candidate characters to use for code generation.withDefaultMaxAttempts(int defaultMaxAttempts) Specifies the default maximum number of attempts to generate a unique code.withRandom(Random random) Specifies theRandomto use for code generation.withRandomSupplier(Supplier<Random> randomSupplier) Specifies a supplier for theRandomto use for code generation.Specifies to use aSecureRandomfor code generation.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
rejecting
Specifies rejection criteria for generated codes.- Parameters:
rejection- the rejection predicate- Returns:
- this builder
-
rejectingSubstrings
Rejects generated codes that contain substrings matching the provided rejection predicate.- Parameters:
rejection- the substring rejection predicate- Returns:
- this builder
-
rejectingOffensiveWords
Rejects the offensive words provided by theOffensiveWordFilter.- Parameters:
offensiveWords- the offensive word filter- Returns:
- this builder
-
withRandomSupplier
Specifies a supplier for theRandomto use for code generation.- Parameters:
randomSupplier- the random supplier- Returns:
- this builder
-
withRandom
Specifies theRandomto use for code generation.- Parameters:
random- the random generator- Returns:
- this builder
-
withSecureRandom
Specifies to use aSecureRandomfor code generation.- Returns:
- this builder
-
withCandidates
Specifies the candidate characters to use for code generation.- Parameters:
candidates- the candidate characters- Returns:
- this builder
-
withDefaultMaxAttempts
Specifies the default maximum number of attempts to generate a unique code.- Parameters:
defaultMaxAttempts- the default maximum attempts- Returns:
- this builder
-
build
Builds the UniqueCodeGenerator with the specified configuration.- Returns:
- the UniqueCodeGenerator
-