Package build.buf.protovalidate
Class ValidatorFactory.ValidatorBuilder
java.lang.Object
build.buf.protovalidate.ValidatorFactory.ValidatorBuilder
- Enclosing class:
ValidatorFactory
A builder class used for building a validator.
-
Method Summary
Modifier and TypeMethodDescriptionbuild()Build a new validatorbuildWithDescriptors(List<com.google.protobuf.Descriptors.Descriptor> descriptors, boolean disableLazy) Build the validator, warming up the cache with any provided descriptors.withConfig(Config config) Create a validator with the given config
-
Method Details
-
withConfig
Create a validator with the given config- Parameters:
config- TheConfigto configure the validator.- Returns:
- The builder instance
-
build
Build a new validator- Returns:
- A new
Validatorinstance.
-
buildWithDescriptors
public Validator buildWithDescriptors(List<com.google.protobuf.Descriptors.Descriptor> descriptors, boolean disableLazy) throws CompilationException, IllegalStateException Build the validator, warming up the cache with any provided descriptors.- Parameters:
descriptors- the list of descriptors to warm up the cache.disableLazy- whether to disable lazy loading of validation rules. When validation is performed, a message's rules will be looked up in a cache. If they are not found, by default they will be processed and lazily-loaded into the cache. Setting this to false will not attempt to lazily-load descriptor information not found in the cache and essentially makes the entire cache read-only, eliminating thread contention.- Returns:
- A new
Validatorinstance. - Throws:
CompilationException- If any of the given descriptors' validation rules fail processing while warming up the cache.IllegalStateException- If disableLazy is set to true and no descriptors are passed.
-