Annotation Interface Spec


@Retention(RUNTIME) @Target({PARAMETER,TYPE}) public @interface Spec
Author:
Tomasz Kaczmarzyk, Matt S.Y. Ho
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    Attribute name (or more generally, path in the entity graph) to be filtered.
    Class<? extends org.springframework.data.jpa.domain.Specification>
    Type of the filter to apply.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
     
    The constant value designed for specification without related HTTP param.
    The default value to use as a fallback when the request parameter is not provided or has an empty value.
     
    Please remember about adding required Maven dependenecy to your project before using jsonPaths.
    Attribute is used to specify behaviour on missing path variable.
     
    HTTP query parameter name (or names) to be used for matching with entity attributes.
    char
    Character used to param delimitation.
    boolean
    Attribute determines that provided params value is in SpEL (Spring Expression Language) format.
     
    boolean
    Attribute determines that constVal/defaultVal value is in SpEL (Spring Expression Language) format.
  • Element Details

    • path

      String path

      Attribute name (or more generally, path in the entity graph) to be filtered.

      For example, consider a Customer entity with field String firstName. If you want to filter customers by id, set @Spec.path attribute to "id".

    • spec

      Class<? extends org.springframework.data.jpa.domain.Specification> spec
      Type of the filter to apply. This should be class that implements Specification interface. Use one of the built-in classes or implement your own. Built-in classes typically extend PathSpecification and are described in README.md
      See Also:
    • params

      String[] params

      HTTP query parameter name (or names) to be used for matching with entity attributes.

      For example, setting params to "name" will mean that you expect ?name=Value in upcoming HTTP requests.

      If not set (and headers and pathVars are not used), then defaults to the same name as the filtered attribute of the entity (see path).

      Default:
      {}
    • paramSeparator

      char paramSeparator
      Character used to param delimitation. Param delimitation is skipped when separator has a 0 value.
      Default:
      '\u0000'
    • pathVars

      String[] pathVars
      Default:
      {}
    • headers

      String[] headers
      Default:
      {}
    • jsonPaths

      String[] jsonPaths
      Please remember about adding required Maven dependenecy to your project before using jsonPaths. See README.md for details.
      Default:
      {}
    • config

      String[] config
      Default:
      {}
    • constVal

      String[] constVal
      The constant value designed for specification without related HTTP param. Const value can be a raw string or SpEL expression. SpEL expression require valueInSpEL to be set to true and SpecificationArgumentResolver to be properly with the AbstractApplicationContext, see README.md for details.

      Supplying constVal() implicitly sets defaultVal() to empty

      Default:
      {}
    • defaultVal

      String[] defaultVal
      The default value to use as a fallback when the request parameter is not provided or has an empty value. Default value can be a raw string or SpEL expression (could SpecificationArgumentResolver. SpEL expression require valueInSpEL to be set to true and SpecificationArgumentResolver to be properly with the AbstractApplicationContext, see README.md for details.

      Supplying constVal() implicitly sets defaultVal() to empty

      Default:
      {}
    • valueInSpEL

      boolean valueInSpEL
      Attribute determines that constVal/defaultVal value is in SpEL (Spring Expression Language) format. Attribute is ignored when SpEL support is disabled, see README.md to get more information about enabling/disabling SpEL support.
      Default:
      false
    • paramsInSpEL

      boolean paramsInSpEL
      Attribute determines that provided params value is in SpEL (Spring Expression Language) format. Attribute is ignored when SpEL support is disabled, see README.md to get more information about enabling/disabling SpEL support.
      Default:
      false
    • onTypeMismatch

      OnTypeMismatch onTypeMismatch
      Default:
      EMPTY_RESULT
    • missingPathVarPolicy

      MissingPathVarPolicy missingPathVarPolicy
      Attribute is used to specify behaviour on missing path variable. Missing param policy should be set to IGNORE when controller endpoint contains multiple paths with different path variables. For more details see README.md
      Default:
      EXCEPTION