1+ package com .relogiclabs .json .schema .internal .message ;
2+
3+ import com .relogiclabs .json .schema .message .ActualDetail ;
4+ import com .relogiclabs .json .schema .types .JArray ;
5+ import com .relogiclabs .json .schema .types .JNode ;
6+ import com .relogiclabs .json .schema .types .JProperty ;
7+
8+ import static com .relogiclabs .json .schema .internal .message .MessageHelper .getTypeName ;
9+ import static com .relogiclabs .json .schema .internal .util .StringHelper .quote ;
10+
11+ public class ActualHelper {
12+
13+ private ActualHelper () {
14+ throw new UnsupportedOperationException ();
15+ }
16+
17+ public static ActualDetail asArrayElementNotFound (JArray array , int index ) {
18+ return new ActualDetail (array , "not found" );
19+ }
20+
21+ public static ActualDetail asValueMismatch (JNode node ) {
22+ return new ActualDetail (node , "found " , node .getOutline ());
23+ }
24+
25+ public static ActualDetail asInvalidDataType (JNode node ) {
26+ return new ActualDetail (node , "applied on non-composite type " ,
27+ getTypeName (node ));
28+ }
29+
30+ public static ActualDetail asDataTypeMismatch (JNode node ) {
31+ return new ActualDetail (node , "found " , getTypeName (node ),
32+ " inferred by " , node .getOutline ());
33+ }
34+
35+ public static ActualDetail asPropertyNotFound (JNode node , JProperty property ) {
36+ return new ActualDetail (node , "not found property key " , quote (property .getKey ()));
37+ }
38+
39+ public static ActualDetail asUndefinedProperty (JProperty property ) {
40+ return new ActualDetail (property , "property found {" , property .getOutline (), "}" );
41+ }
42+
43+ public static ActualDetail asPropertyOrderMismatch (JNode node ) {
44+ return node instanceof JProperty property
45+ ? new ActualDetail (property , "key " , quote (property .getKey ()), " is found at position" )
46+ : new ActualDetail (node , "key not found at position" );
47+ }
48+
49+ public static ActualDetail asInvalidFunction (JNode node ) {
50+ return new ActualDetail (node , "applied on non-composite type " , getTypeName (node ));
51+ }
52+ }
0 commit comments