Class BeanValidationProcessor

java.lang.Object
org.instancio.internal.beanvalidation.BeanValidationProcessor
All Implemented Interfaces:
GeneratorSpecProcessor

public class BeanValidationProcessor extends Object implements GeneratorSpecProcessor
This class is the entry point for processing Bean Validation annotations.

The main goals of this implementation are:

  • support single annotations
  • support combinations of annotations from different providers
  • produce repeatable results regardless of declaration order

All of the above is done on a best-effort basis and is not guaranteed to work in all circumstances.

When multiple annotations are declared, the processor first determines and consumes the primary annotation. Primary annotations are those that can only be applied to a certain type and have a certain meaning, e.g. @Email, @URL, @UUID. Currently, all supported primary annotations target character sequences. Once a primary annotation has been consumed, the processor will apply the remaining annotations.

  • Constructor Details

    • BeanValidationProcessor

      public BeanValidationProcessor()
  • Method Details

    • process

      public void process(@NotNull @NotNull GeneratorSpec<?> spec, @NotNull @NotNull Class<?> targetClass, @Nullable @Nullable Field field)
      Description copied from interface: GeneratorSpecProcessor
      Processes given generator spec.

      The targetClass parameter may differ from Field.getType(). This could be the case where the field is declared using a TypeVariable, in which case field's type will be Object. Alternatively, a subtype may have been specified via the API.

      Specified by:
      process in interface GeneratorSpecProcessor
      Parameters:
      spec - generator spec to process
      targetClass - class being generated
      field - field the generated value will be assigned to