in extensions/openstack/runtime/src/main/java/org/apache/camel/quarkus/component/openstack/graal/OSBadBooleanDeserializerSubstitutions.java [42:81]
public Boolean deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
JsonToken t = jp.getCurrentToken();
if (t == JsonToken.VALUE_TRUE) {
return Boolean.TRUE;
}
if (t == JsonToken.VALUE_FALSE) {
return Boolean.FALSE;
}
// [JACKSON-78]: should accept ints too, (0 == false, otherwise true)
if (t == JsonToken.VALUE_NUMBER_INT) {
// 11-Jan-2012, tatus: May be outside of int...
if (jp.getNumberType() == JsonParser.NumberType.INT) {
return (jp.getIntValue() == 0) ? Boolean.FALSE : Boolean.TRUE;
}
return Boolean.valueOf(_parseBooleanFromNumber(jp, ctxt));
}
if (t == JsonToken.VALUE_NULL) {
return null;
}
// And finally, let's allow Strings to be converted too
if (t == JsonToken.VALUE_STRING) {
String text = jp.getText().trim();
if ("true".equalsIgnoreCase(text)) {
return Boolean.TRUE;
}
if ("false".equalsIgnoreCase(text)) {
return Boolean.FALSE;
}
if (text.length() == 0) {
return null;
}
throw ctxt.weirdStringException(text, Boolean.class, "only \"true\" or \"false\" recognized");
}
ctxt.handleUnexpectedToken(Boolean.class, ctxt.getParser());
// Otherwise, no can do:
throw JsonMappingException.from(ctxt.getParser(),
String.format("Cannot deserialize instance of %s out of %s token",
ClassUtil.nameOf(Boolean.class), t));
}