Class GenericValidator<S extends org.camunda.bpm.model.xml.instance.ModelElementInstance,T extends org.camunda.bpm.model.xml.instance.ModelElementInstance>

java.lang.Object
de.redsix.dmncheck.validators.core.GenericValidator<S,T>
Type Parameters:
S - Class used to check whether the validation is applicable
T - Class used for validation
All Implemented Interfaces:
Validator
Direct Known Subclasses:
AggregationOutputTypeValidator, SimpleValidator

public abstract class GenericValidator<S extends org.camunda.bpm.model.xml.instance.ModelElementInstance,T extends org.camunda.bpm.model.xml.instance.ModelElementInstance> extends Object implements Validator
Generic validator that facilitates writing validations directly on the structure of the DMN model instance.

Note: We are using the Camunda implementation of the DMN model (...).

To write a validation using this validator you have to specify:

1) The element type (T) that is validated 2) The element type (S) that is used to check whether the validation is applicable

The validator collects all elements of type S and checks whether the validation is applicable. It then applies the validation on all child elements of type T.

  • Constructor Details

    • GenericValidator

      public GenericValidator()
  • Method Details

    • isApplicable

      protected abstract boolean isApplicable(S element, ValidationContext validationContext)
      Checks whether the validation is applicable for an element of type S taking account of the validation context.
      Parameters:
      element - Element used to check applicability of the validation
      validationContext - Validation Context
      Returns:
      Whether the validation is applicable
    • validate

      protected abstract List<ValidationResult> validate(T element, ValidationContext validationContext)
      Validates a given element of type T.

      A validation context can be used to track global assumptions about the DMN model instance.

      Parameters:
      element - Element under validation
      validationContext - Validation Context
      Returns:
      A list of validation results
    • getClassUsedToCheckApplicability

      protected abstract Class<S> getClassUsedToCheckApplicability()
      Auxiliary method to determine the class used for the applicability check.
      Returns:
      Class used to check whether the validation is applicable
    • getClassUnderValidation

      protected abstract Class<T> getClassUnderValidation()
      Auxiliary method to determine the class for the validation.
      Returns:
      Class used for validation
    • apply

      public List<ValidationResult> apply(org.camunda.bpm.model.dmn.DmnModelInstance dmnModelInstance)
      Description copied from interface: Validator
      Validates the given DMN model instance and returns the validation results as a list.
      Specified by:
      apply in interface Validator
      Parameters:
      dmnModelInstance - DMN model instance used for validation
      Returns:
      A possibly empty list of validation results