Annotation Type Constraint


  • @Repeatable(Constraints.class)
    @Target(TYPE)
    @Retention(RUNTIME)
    public @interface Constraint
    An annotation interface that represents a formal constraint (invariant)

    Constraints can be computationally evaluated using a FHIRPath engine or an instance of ConstraintValidator.

    • Required Element Summary

      Required Elements 
      Modifier and Type Required Element Description
      java.lang.String description
      A description used in messages identifying that the constraint has been violated
      java.lang.String expression
      A FHIRPath expression that must evaluate to true when run on the validation target Element or Resource
      java.lang.String id
      Identifies the constraint uniquely amongst all the constraints in the context
      java.lang.String level
      The severity of the constraint
      java.lang.String location
      The location (path) of the validation target Element or Resource
      java.lang.String source
      The original source of the constraint
    • Field Detail

      • LEVEL_RULE

        static final java.lang.String LEVEL_RULE
      • LEVEL_WARNING

        static final java.lang.String LEVEL_WARNING
      • LOCATION_BASE

        static final java.lang.String LOCATION_BASE
      • SOURCE_UNKNOWN

        static final java.lang.String SOURCE_UNKNOWN
      • location

        java.lang.String location
        The location (path) of the validation target Element or Resource
        Returns:
        the location
        See Also:
        ElementDefinition.getPath()
      • modelChecked

        boolean modelChecked
        Indicates whether the constraint is checked in the model
        Returns:
        true if the constraint is checked in the model, false otherwise
        Default:
        false
      • generated

        boolean generated
        Indicates whether the constraint was generated
        Returns:
        true if the constraint was generated, false otherwise
        Default:
        false
      • validatorClass

        java.lang.Class<? extends ConstraintValidator<?>> validatorClass
        The ConstraintValidator class used to validate this constraint
        Returns:
        the ConstraintValidator class used to validate this constraint
        Default:
        org.linuxforhealth.fhir.model.annotation.Constraint.FHIRPathConstraintValidator.class