1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.logging.log4j.catalog.api.annotation;
17
18 import org.springframework.context.annotation.Condition;
19 import org.springframework.context.annotation.ConditionContext;
20 import org.springframework.core.env.Environment;
21 import org.springframework.core.type.AnnotatedTypeMetadata;
22 import org.springframework.util.MultiValueMap;
23
24
25
26
27 public class PropertyExistsCondition implements Condition {
28 @Override
29 public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
30 Environment env = context.getEnvironment();
31 MultiValueMap<String, Object> attrs = metadata.getAllAnnotationAttributes(ConditionOnPropertyExists.class.getName());
32 if (attrs != null) {
33 Object value = attrs.get("value");
34 return value != null && null != env && env.getProperty(value.toString()) != null;
35 }
36 return false;
37 }
38 }