Interface Condition

All Known Subinterfaces:
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface Condition
A single condition that must be matched in order for a component to be registered.

Conditions are checked immediately before the bean definition is due to be registered and are free to veto registration based on any criteria that can be determined at that point.

Conditions must follow the same restrictions as a BeanFactoryPostProcessor and take care to never interact with bean instances. For more fine-grained control over conditions that interact with @Configuration beans, consider implementing the ConfigurationCondition interface.

Multiple conditions on a given class or on a given method will be ordered according to the semantics of Spring's Ordered interface and @Order annotation. See AnnotationAwareOrderComparator for details.

Phillip Webb, Sam Brannen
See Also:
  • Method Details

    • matches

      boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata)
      Determine if the condition matches.
      context - the condition context
      metadata - the metadata of the class or method being checked
      true if the condition matches and the component can be registered, or false to veto the annotated component's registration