}
throw new IllegalStateException("Current node of type " + n.getClass().getName());
}
static JsonToken forConfigValue(ConfigValue configValue) {
ConfigValueType valueType = configValue.valueType();
switch (valueType) {
case NUMBER:
if (configValue.unwrapped() instanceof Double) {
return JsonToken.VALUE_NUMBER_FLOAT;
} else {
return JsonToken.VALUE_NUMBER_INT;
}
case BOOLEAN:
if (configValue.unwrapped().equals(Boolean.TRUE)) {
return JsonToken.VALUE_TRUE;
} else {
return JsonToken.VALUE_FALSE;
}
case NULL:
return JsonToken.VALUE_NULL;
case STRING:
return JsonToken.VALUE_STRING;
case OBJECT:
return JsonToken.START_OBJECT;
case LIST:
return JsonToken.START_ARRAY;
default:
// not possible unless the set of enums changes on us later
throw new IllegalArgumentException(valueType.name() + " is not a supported ConfigValueType");
}
}