1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package com.helger.schematron.svrl;
18
19 import java.io.Serializable;
20
21 import javax.annotation.Nonnull;
22 import javax.annotation.Nullable;
23
24 import org.oclc.purl.dsdl.svrl.FailedAssert;
25 import org.oclc.purl.dsdl.svrl.SuccessfulReport;
26
27 import com.helger.commons.ValueEnforcer;
28 import com.helger.commons.annotation.DevelopersNote;
29 import com.helger.commons.error.level.IErrorLevel;
30 import com.helger.commons.string.StringHelper;
31
32
33
34
35
36
37 @FunctionalInterface
38 public interface ISVRLErrorLevelDeterminator extends Serializable
39 {
40
41
42
43
44
45
46
47
48 @Nonnull
49 @Deprecated
50 @DevelopersNote ("Use getErrorLevelFromString instead")
51 default IErrorLevel getErrorLevelFromFlag (@Nullable final String sFlag)
52 {
53 return getErrorLevelFromString (sFlag);
54 }
55
56
57
58
59
60
61
62
63
64
65 @Nonnull
66 IErrorLevel getErrorLevelFromString (@Nullable String sValue);
67
68
69
70
71
72
73
74
75 @Nonnull
76 default IErrorLevel getErrorLevelFromFailedAssert (@Nonnull final FailedAssert aFailedAssert)
77 {
78 ValueEnforcer.notNull (aFailedAssert, "FailedAssert");
79
80
81 String sValue = aFailedAssert.getFlag ();
82 if (StringHelper.hasNoText (sValue))
83 {
84
85 sValue = aFailedAssert.getRole ();
86 }
87 return getErrorLevelFromString (sValue);
88 }
89
90
91
92
93
94
95
96
97 @Nonnull
98 default IErrorLevel getErrorLevelFromSuccessfulReport (@Nonnull final SuccessfulReport aSuccessfulReport)
99 {
100 ValueEnforcer.notNull (aSuccessfulReport, "SuccessfulReport");
101
102
103 String sValue = aSuccessfulReport.getFlag ();
104 if (StringHelper.hasNoText (sValue))
105 {
106
107 sValue = aSuccessfulReport.getRole ();
108 }
109 return getErrorLevelFromString (sValue);
110 }
111 }