class StreamlineEventSerializer implements Serializer<StreamlineEvent> {

    static Object getAvroRecord (StreamlineEvent streamlineEvent, Schema schema) {
        if (streamlineEvent.containsKey(StreamlineEvent.PRIMITIVE_PAYLOAD_FIELD)) {
            if (streamlineEvent.keySet().size() > 1) {
                throw new RuntimeException("Invalid schema, primitive schema can contain only one field.");
            }
            return streamlineEvent.get(StreamlineEvent.PRIMITIVE_PAYLOAD_FIELD);
        }
        GenericRecord result;
        result = new GenericData.Record(schema);
        for (Map.Entry<String, Object> entry: streamlineEvent.entrySet()) {
            result.put(entry.getKey(), getAvroValue(entry.getValue(), schema.getField(entry.getKey()).schema()));
        }
        return result;
    }

    public  StreamlineEventSerializer();

}