Annotation Interface ConditionalOnBooleanProperty


@Retention(RUNTIME) @Target({TYPE,METHOD}) @Documented @Conditional(org.springframework.boot.autoconfigure.condition.OnPropertyCondition.class) public @interface ConditionalOnBooleanProperty
@Conditional that checks if the specified properties have a specific boolean value. By default the properties must be present in the Environment and equal to true. The havingValue() and matchIfMissing() attributes allow further customizations.

If the property is not contained in the Environment at all, the matchIfMissing() attribute is consulted. By default missing attributes do not match.

Since:
3.5.0
Author:
Phillip Webb
See Also:
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    boolean
    The expected value for the properties.
    boolean
    Specify if the condition should match if the property is not set.
    The name of the properties to test.
    A prefix that should be applied to each property.
    Alias for name().
  • Element Details

    • value

      String[] value
      Alias for name().
      Returns:
      the names
      Default:
      {}
    • prefix

      String prefix
      A prefix that should be applied to each property. The prefix automatically ends with a dot if not specified. A valid prefix is defined by one or more words separated with dots (e.g. "acme.system.feature").
      Returns:
      the prefix
      Default:
      ""
    • name

      String[] name
      The name of the properties to test. If a prefix has been defined, it is applied to compute the full key of each property. For instance if the prefix is app.config and one value is my-value, the full key would be app.config.my-value

      Use the dashed notation to specify each property, that is all lower case with a "-" to separate words (e.g. my-long-property).

      If multiple names are specified, all of the properties have to pass the test for the condition to match.

      Returns:
      the names
      Default:
      {}
    • havingValue

      boolean havingValue
      The expected value for the properties. If not specified, the property must be equal to true.
      Returns:
      the expected value
      Default:
      true
    • matchIfMissing

      boolean matchIfMissing
      Specify if the condition should match if the property is not set. Defaults to false.
      Returns:
      if the condition should match if the property is missing
      Default:
      false