3030
3131import java .text .MessageFormat ;
3232import java .util .Arrays ;
33- import java .util .HashMap ;
3433import java .util .Map ;
3534import java .util .function .Supplier ;
3635
4443 */
4544@ JsonIgnoreProperties ({ "messageSupplier" , "schemaNode" , "instanceNode" , "valid" })
4645@ JsonPropertyOrder ({ "keyword" , "instanceLocation" , "message" , "evaluationPath" , "schemaLocation" ,
47- "messageKey" , "arguments" , "details" })
46+ "messageKey" , "arguments" , "details" , "property" , "index" })
4847@ JsonInclude (Include .NON_NULL )
4948public class Error {
5049 private final String keyword ;
@@ -60,10 +59,12 @@ public class Error {
6059 private final Map <String , Object > details ;
6160 private final JsonNode instanceNode ;
6261 private final JsonNode schemaNode ;
62+ private final String property ;
63+ private final Integer index ;
6364
6465 Error (String keyword , NodePath evaluationPath , SchemaLocation schemaLocation ,
6566 NodePath instanceLocation , Object [] arguments , Map <String , Object > details ,
66- String messageKey , Supplier <String > messageSupplier , JsonNode instanceNode , JsonNode schemaNode ) {
67+ String messageKey , Supplier <String > messageSupplier , JsonNode instanceNode , JsonNode schemaNode , String property , Integer index ) {
6768 super ();
6869 this .keyword = keyword ;
6970 this .instanceLocation = instanceLocation ;
@@ -75,6 +76,8 @@ public class Error {
7576 this .messageSupplier = messageSupplier ;
7677 this .instanceNode = instanceNode ;
7778 this .schemaNode = schemaNode ;
79+ this .property = property ;
80+ this .index = index ;
7881 }
7982
8083 /**
@@ -142,17 +145,11 @@ public JsonNode getSchemaNode() {
142145 * @return the property name
143146 */
144147 public String getProperty () {
145- if (details == null ) {
146- return null ;
147- }
148- return (String ) getDetails ().get ("property" );
148+ return this .property ;
149149 }
150150
151151 public Integer getIndex () {
152- if (details == null ) {
153- return null ;
154- }
155- return (Integer ) getDetails ().get ("index" );
152+ return this .index ;
156153 }
157154
158155 public Object [] getArguments () {
@@ -207,6 +204,8 @@ public boolean equals(Object o) {
207204 if (evaluationPath != null ? !evaluationPath .equals (that .evaluationPath ) : that .evaluationPath != null ) return false ;
208205 if (details != null ? !details .equals (that .details ) : that .details != null ) return false ;
209206 if (messageKey != null ? !messageKey .equals (that .messageKey ) : that .messageKey != null ) return false ;
207+ if (property != null ? !property .equals (that .property ) : that .property != null ) return false ;
208+ if (index != null ? !index .equals (that .index ) : that .index != null ) return false ;
210209 return Arrays .equals (arguments , that .arguments );
211210 }
212211
@@ -218,6 +217,8 @@ public int hashCode() {
218217 result = 31 * result + (details != null ? details .hashCode () : 0 );
219218 result = 31 * result + (arguments != null ? Arrays .hashCode (arguments ) : 0 );
220219 result = 31 * result + (messageKey != null ? messageKey .hashCode () : 0 );
220+ result = 31 * result + (property != null ? property .hashCode () : 0 );
221+ result = 31 * result + (index != null ? index .hashCode () : 0 );
221222 return result ;
222223 }
223224
@@ -252,25 +253,21 @@ public static abstract class BuilderSupport<S> {
252253 protected String messageKey ;
253254 protected JsonNode instanceNode ;
254255 protected JsonNode schemaNode ;
256+ protected String property ;
257+ protected Integer index ;
255258
256259 public S keyword (String keyword ) {
257260 this .keyword = keyword ;
258261 return self ();
259262 }
260263
261- public S property (String properties ) {
262- if (this .details == null ) {
263- this .details = new HashMap <>();
264- }
265- this .details .put ("property" , properties );
264+ public S property (String property ) {
265+ this .property = property ;
266266 return self ();
267267 }
268268
269269 public S index (Integer index ) {
270- if (this .details == null ) {
271- this .details = new HashMap <>();
272- }
273- this .details .put ("index" , index );
270+ this .index = index ;
274271 return self ();
275272 }
276273
@@ -388,7 +385,7 @@ public Error build() {
388385 });
389386 }
390387 return new Error (keyword , evaluationPath , schemaLocation , instanceLocation ,
391- arguments , details , messageKey , messageSupplier , this .instanceNode , this .schemaNode );
388+ arguments , details , messageKey , messageSupplier , this .instanceNode , this .schemaNode , this . property , this . index );
392389 }
393390
394391 protected Object [] getMessageArguments () {
0 commit comments