All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.clickzetta.client.jdbc.arrow.util.CZJsonStringHashMap Maven / Gradle / Ivy

There is a newer version: 2.0.0
Show newest version
package com.clickzetta.client.jdbc.arrow.util;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * Simple class that extends the regular java.util.HashMap but overrides the
 * toString() method of the HashMap class to produce a JSON string instead
 *
 * @param  The type of the key for the map.
 * @param  The type of the value for the map.
 */
public class CZJsonStringHashMap extends LinkedHashMap {

  @Override
  public final String toString() {
    List entries = new ArrayList<>(entrySet().size());
    for (Map.Entry entry : entrySet()) {
      entries.add(String.join(":",
        JsonUtils.convert(entry.getKey()), JsonUtils.convert(entry.getValue())));
    }
    return "{" + String.join(",", entries) + "}";
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy