import org.apache.olingo.commons.api.data.Property; //导入方法依赖的package包/类
/**
* Writes primitive property into json.
*
* @param type
* the EDM type
* @param property
* property instance
* @param options
* options for the serializer
* @param json
* json generator
* @throws EdmPrimitiveTypeException
* if any error occurred
* @throws IOException
* if any error occurred
* @throws SerializerException
* if any error occurred
*/
private void writePrimitive(EdmPrimitiveType type, Property property,
PrimitiveSerializerOptions options, JsonGenerator json)
throws EdmPrimitiveTypeException, IOException, SerializerException {
Boolean isNullable = options == null ? null : options.isNullable();
Integer maxLength = options == null ? null : options.getMaxLength();
Integer precision = options == null ? null : options.getPrecision();
Integer scale = options == null ? null : options.getScale();
Boolean isUnicode = options == null ? null : options.isUnicode();
if (property.isPrimitive()) {
writePrimitiveValue(property.getName(), type, property.asPrimitive(), isNullable,
maxLength, precision, scale, isUnicode, json);
} else if (property.isGeospatial()) {
throw new SerializerException("Property type not yet supported!",
SerializerException.MessageKeys.UNSUPPORTED_PROPERTY_TYPE, property.getName());
} else if (property.isEnum()) {
writePrimitiveValue(property.getName(), type, property.asEnum(), isNullable, maxLength,
precision, scale, isUnicode, json);
} else {
throw new SerializerException("Inconsistent property type!",
SerializerException.MessageKeys.INCONSISTENT_PROPERTY_TYPE, property.getName());
}
}