@@ -103,6 +103,8 @@ public AbstractElement query(String query) {
103103 }
104104
105105 public AbstractElement query (String query , AbstractElement orElse ) {
106+ if (orElse == null )
107+ orElse = AbstractNull .VALUE ;
106108 AbstractElement value = query (query );
107109 return (value != null && !value .isNull ()) ? value : orElse ;
108110 }
@@ -168,23 +170,23 @@ public String string(String key) throws AbstractCoercingException {
168170 }
169171
170172 public String string (String key , String orElse ) throws AbstractCoercingException {
171- return query (key , new AbstractPrimitive (orElse )).string ();
173+ return query (key , orElse == null ? AbstractNull . VALUE : new AbstractPrimitive (orElse )).string ();
172174 }
173175
174176 public Boolean bool (String key ) throws AbstractCoercingException {
175177 return query (key , AbstractNull .VALUE ).bool ();
176178 }
177179
178180 public Boolean bool (String key , Boolean orElse ) throws AbstractCoercingException {
179- return query (key , new AbstractPrimitive (orElse )).bool ();
181+ return query (key , orElse == null ? AbstractNull . VALUE : new AbstractPrimitive (orElse )).bool ();
180182 }
181183
182184 public Number number (String key ) throws AbstractCoercingException {
183185 return query (key , AbstractNull .VALUE ).number ();
184186 }
185187
186188 public Number number (String key , Number orElse ) throws AbstractCoercingException {
187- return query (key , new AbstractPrimitive (orElse )).number ();
189+ return query (key , orElse == null ? AbstractNull . VALUE : new AbstractPrimitive (orElse )).number ();
188190 }
189191
190192 public Object toObject () {
0 commit comments