use of com.linkedin.avroutil1.parser.Located in project avro-util by linkedin.
the class AvscParser method getOptionalInteger.
private Located<Integer> getOptionalInteger(JsonObjectExt node, String prop, AvscFileParseContext context) {
JsonValueExt val = node.get(prop);
if (val == null) {
return null;
}
JsonValue.ValueType valType = val.getValueType();
if (valType != JsonValue.ValueType.NUMBER) {
context.addIssue(AvscIssues.badPropertyType(prop, locationOf(context.getUri(), val), val, valType.name(), JsonValue.ValueType.NUMBER.name()));
return null;
}
JsonNumberExt numberNode = (JsonNumberExt) val;
if (!numberNode.isIntegral()) {
context.addIssue(AvscIssues.badPropertyType(prop, locationOf(context.getUri(), val), val, "floating point value", "integer"));
return null;
}
return new Located<>(numberNode.intValueExact(), Util.convertLocation(val.getStartLocation()));
}
use of com.linkedin.avroutil1.parser.Located in project avro-util by linkedin.
the class AvscParser method getOptionalString.
private Located<String> getOptionalString(JsonObjectExt node, String prop) {
JsonValueExt val = node.get(prop);
if (val == null) {
return null;
}
JsonValue.ValueType valType = val.getValueType();
if (valType != JsonValue.ValueType.STRING) {
throw new AvroSyntaxException("\"" + prop + "\" property at " + val.getStartLocation() + " is expected to be a string, not a " + JsonPUtil.describe(valType) + " (" + val + ")");
}
return new Located<>(((JsonStringExt) val).getString(), Util.convertLocation(val.getStartLocation()));
}
Aggregations