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.util.Locale;
20
21 import javax.annotation.Nonnull;
22 import javax.annotation.Nullable;
23
24 import com.helger.commons.ValueEnforcer;
25 import com.helger.commons.error.SingleError;
26 import com.helger.commons.error.level.IErrorLevel;
27 import com.helger.commons.error.text.IHasErrorText;
28 import com.helger.commons.hashcode.HashCodeGenerator;
29 import com.helger.commons.location.ILocation;
30 import com.helger.commons.string.ToStringGenerator;
31
32
33
34
35
36
37
38 public class SVRLResourceError extends SingleError
39 {
40 private final String m_sTest;
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61 public SVRLResourceError (@Nonnull final IErrorLevel aErrorLevel,
62 @Nullable final String sErrorID,
63 @Nullable final String sErrorFieldName,
64 @Nullable final ILocation aErrorLocation,
65 @Nullable final IHasErrorText aErrorText,
66 @Nullable final Throwable aLinkedException,
67 @Nonnull final String sTest)
68 {
69 super (aErrorLevel, sErrorID, sErrorFieldName, aErrorLocation, aErrorText, aLinkedException);
70 m_sTest = ValueEnforcer.notNull (sTest, "Test");
71 }
72
73
74
75
76 @Nonnull
77 public String getTest ()
78 {
79 return m_sTest;
80 }
81
82 @Override
83 public String getAsString (@Nonnull final Locale aContentLocale)
84 {
85 String ret = super.getAsString (aContentLocale);
86 ret += " Test=" + m_sTest;
87 return ret;
88 }
89
90 @Override
91 public boolean equals (final Object o)
92 {
93 if (o == this)
94 return true;
95 if (!super.equals (o))
96 return false;
97 final SVRLResourceError/../com/helger/schematron/svrl/SVRLResourceError.html#SVRLResourceError">SVRLResourceError rhs = (SVRLResourceError) o;
98 return m_sTest.equals (rhs.m_sTest);
99 }
100
101 @Override
102 public int hashCode ()
103 {
104 return HashCodeGenerator.getDerived (super.hashCode ()).append (m_sTest).getHashCode ();
105 }
106
107 @Override
108 public String toString ()
109 {
110 return ToStringGenerator.getDerived (super.toString ()).append ("test", m_sTest).getToString ();
111 }
112
113 public static class SVRLErrorBuilder extends SingleError.AbstractBuilder <SVRLResourceError, SVRLErrorBuilder>
114 {
115 private String m_sTest;
116
117 public SVRLErrorBuilder (@Nonnull final String sTest)
118 {
119 setTest (sTest);
120 }
121
122 @Nonnull
123 public final SVRLErrorBuilder setTest (@Nonnull final String sTest)
124 {
125 m_sTest = ValueEnforcer.notNull (sTest, "Test");
126 return this;
127 }
128
129 @Override
130 public SVRLResourceError build ()
131 {
132 return new SVRLResourceError (m_aErrorLevel,
133 m_sErrorID,
134 m_sErrorFieldName,
135 m_aErrorLocation,
136 m_aErrorText,
137 m_aLinkedException,
138 m_sTest);
139 }
140 }
141 }