1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.logging.log4j.catalog.api;
17
18 import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
19 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
20 import org.apache.logging.log4j.catalog.api.exception.NameNotFoundException;
21 import org.apache.logging.log4j.catalog.api.plugins.ConstraintTypeDeserializer;
22 import org.apache.logging.log4j.catalog.api.plugins.ConstraintTypeSerializer;
23 import org.apache.logging.log4j.core.config.plugins.Plugin;
24
25
26
27
28 @JsonDeserialize(using = ConstraintTypeDeserializer.class)
29 @JsonSerialize(using = ConstraintTypeSerializer.class)
30 public interface ConstraintType {
31
32 public static final String CATEGORY = "Constraint";
33
34 default String getName() {
35 Plugin annotation = this.getClass().getAnnotation(Plugin.class);
36 if (annotation == null || annotation.name().length() == 0) {
37 throw new NameNotFoundException("No name could be found for plugin class " + this.getClass().getName());
38 }
39
40 return annotation.name();
41 }
42
43 void validate(boolean isRequestContext, String name, String value, String constraintValue, StringBuilder error);
44
45 }