@@ -43,6 +43,10 @@ protected Object resolveCollection(PropertyTokenizer prop, Object object) {
43
43
}
44
44
45
45
protected Object getCollectionValue (PropertyTokenizer prop , Object collection ) {
46
+ if (collection == null ) {
47
+ throw new ReflectionException ("Cannot get the value '" + prop .getIndexedName () + "' because the property '"
48
+ + prop .getName () + "' is null." );
49
+ }
46
50
if (collection instanceof Map ) {
47
51
return ((Map ) collection ).get (prop .getIndex ());
48
52
}
@@ -68,12 +72,16 @@ protected Object getCollectionValue(PropertyTokenizer prop, Object collection) {
68
72
} else if (collection instanceof short []) {
69
73
return ((short []) collection )[i ];
70
74
} else {
71
- throw new ReflectionException (
72
- "The '" + prop .getName () + "' property of " + collection + " is not a List or Array." );
75
+ throw new ReflectionException ("Cannot get the value '" + prop . getIndexedName () + "' because the property '"
76
+ + prop .getName () + "' is not Map, List or Array." );
73
77
}
74
78
}
75
79
76
80
protected void setCollectionValue (PropertyTokenizer prop , Object collection , Object value ) {
81
+ if (collection == null ) {
82
+ throw new ReflectionException ("Cannot set the value '" + prop .getIndexedName () + "' because the property '"
83
+ + prop .getName () + "' is null." );
84
+ }
77
85
if (collection instanceof Map ) {
78
86
((Map ) collection ).put (prop .getIndex (), value );
79
87
} else {
@@ -99,8 +107,8 @@ protected void setCollectionValue(PropertyTokenizer prop, Object collection, Obj
99
107
} else if (collection instanceof short []) {
100
108
((short []) collection )[i ] = (Short ) value ;
101
109
} else {
102
- throw new ReflectionException (
103
- "The '" + prop .getName () + "' property of " + collection + " is not a List or Array." );
110
+ throw new ReflectionException ("Cannot set the value '" + prop . getIndexedName () + "' because the property '"
111
+ + prop .getName () + "' is not Map, List or Array." );
104
112
}
105
113
}
106
114
}
0 commit comments