class InfluxDbWriteObjectSerializer {

    public String getGroupedLineProtocolString(InfluxDbWriteObject influxDbWriteObject, String realMeasurement) {
        // First develop a set of timestamps.
        HashSet<Long> times = new HashSet<>();
        for (InfluxDbPoint point : influxDbWriteObject.getPoints()) {
            times.add(point.getTime());
        }

        // Write lines, one per timestamp, instead of one per point.  Collect tags from one point
        // as all are presumed the same.
        StringBuilder stringBuilder = new StringBuilder();
        for (Long time : times) {
            Map<String, Object> fields = new HashMap<>();
            Map<String, String> tags = null;
            
            for (InfluxDbPoint point : influxDbWriteObject.getPoints()) {
                if (point.getTime().equals(time)) {
                    mergeFields(fields, point.getFields(), point.getMeasurement());
                    tags = point.getTags();
                }
            }
            lineProtocol(tags, fields, realMeasurement, time, influxDbWriteObject.getPrecision(),
                    stringBuilder);
            stringBuilder.append("\n");
        }

        return stringBuilder.toString();
    }

    public  InfluxDbWriteObjectSerializer(String measurementPrefix);

}