I am trying to create a composed annotation that is the inverse of ConditionalOnProperty, i.e., ConditionalOnPropertyMissingOrFalse so that I don't have to repeat the matchIfMissing = true, havingValue = "false" for every usage. I don't want to hard-code the property, so I tried writing a composed (meta) annotation like this:

@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.TYPE, ElementType.METHOD })
@Documented
@ConditionalOnProperty(matchIfMissing = true, havingValue = "false")
public @interface ConditionalOnMissingOrFalseProperty {

    @AliasFor(annotation = ConditionalOnProperty.class)
    String[] value() default {};

    @AliasFor(annotation = ConditionalOnProperty.class)
    String prefix() default "";

    @AliasFor(annotation = ConditionalOnProperty.class)
    String[] name() default {};
}

In looking at OnPropertyCondition, it looks like it's using AnnotatedTypeMetadata#getAllAnnotationAttributes(), which is documented:

this variant does not take attribute overrides into account.

If I understand that correctly, it means that @ConditionalOnProperty is explicitly not supporting composed annotations in the way I've attempted to do? And if I'm correct in that interpretation, is there a reason why?

If it's supposed to support composed annotations, what am I missing?

Comment From: wilkinsona

This appears to be a duplicate of #24968.