Interface ValidatorFactory
-
public interface ValidatorFactory
Creates built-inValidator
instances andValidator
instances loaded by name.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static ValidatorFactory
createServiceFactory(java.lang.ClassLoader classLoader)
Creates a ValidatorFactory that discovers service providers using the given ClassLoader.static ValidatorFactory
createServiceFactory(java.lang.Iterable<Validator> validators, java.lang.Iterable<ValidatorService> services)
Creates a ValidatorFactory that uses a collection of built-in validators and a collection of ValidatorService instances for configurable validators.static ValidatorFactory
createServiceFactory(java.lang.Iterable<Validator> validators, java.lang.Iterable<ValidatorService> services, java.lang.Iterable<ValidationEventDecorator> decorators)
Creates a ValidatorFactory that uses a collection of built-in validators and a collection of ValidatorService instances for configurable validators.java.util.Optional<Validator>
createValidator(java.lang.String name, ObjectNode configuration)
Creates and configures a Validator by name.java.util.List<Validator>
loadBuiltinValidators()
Returns a list of built-in validators that are always applied to a Model regardless of if they are explicitly configured in the metadata of a model.default java.util.List<ValidationEventDecorator>
loadDecorators()
Returns a list of decorators.
-
-
-
Method Detail
-
loadBuiltinValidators
java.util.List<Validator> loadBuiltinValidators()
Returns a list of built-in validators that are always applied to a Model regardless of if they are explicitly configured in the metadata of a model. This is in contrast to validators returns from callingcreateValidator(java.lang.String, software.amazon.smithy.model.node.ObjectNode)
, which are only applied to a model if they are declared in the metadata section of a model.- Returns:
- Returns the loaded validators.
-
loadDecorators
default java.util.List<ValidationEventDecorator> loadDecorators()
Returns a list of decorators.- Returns:
- Returns the loaded decorators.
-
createValidator
java.util.Optional<Validator> createValidator(java.lang.String name, ObjectNode configuration)
Creates and configures a Validator by name.- Parameters:
name
- Name of the validator to create.configuration
- Configuration data used to create the validator.- Returns:
- Returns the created validator wrapped in an Optional.
- Throws:
SourceException
- on configuration error.java.lang.RuntimeException
- if an error occurs while creating.
-
createServiceFactory
static ValidatorFactory createServiceFactory(java.lang.Iterable<Validator> validators, java.lang.Iterable<ValidatorService> services)
Creates a ValidatorFactory that uses a collection of built-in validators and a collection of ValidatorService instances for configurable validators.The validators and services passed to this method are copied into a List before creating the actual factory to avoid holding on to
ServiceLoader
VM-wide instances that potentially utilize a Thread's context ClassLoader.- Parameters:
validators
- Built-in validators to provide from the factory.services
- ValidatorService instances to use to create validators.- Returns:
- Returns the created ValidatorFactory.
-
createServiceFactory
static ValidatorFactory createServiceFactory(java.lang.Iterable<Validator> validators, java.lang.Iterable<ValidatorService> services, java.lang.Iterable<ValidationEventDecorator> decorators)
Creates a ValidatorFactory that uses a collection of built-in validators and a collection of ValidatorService instances for configurable validators.The validators and services passed to this method are copied into a List before creating the actual factory to avoid holding on to
ServiceLoader
VM-wide instances that potentially utilize a Thread's context ClassLoader.- Parameters:
validators
- Built-in validators to provide from the factory.services
- ValidatorService instances to use to create validators.decorators
- ValidationEventDecorator instances to use to create decorators.- Returns:
- Returns the created ValidatorFactory.
-
createServiceFactory
static ValidatorFactory createServiceFactory(java.lang.ClassLoader classLoader)
Creates a ValidatorFactory that discovers service providers using the given ClassLoader.- Parameters:
classLoader
- Class loader used to find ValidatorProviders.- Returns:
- Returns the created factory.
-
-