// Path: SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/utilities/json/JsonParserWrapper.java
// public class JsonParserWrapper {
// 
//     public static List toList(String input) throws JsonSyntaxException {
//         return new Gson().fromJson(input, LinkedList.class);
//     }
// 
// 
//     public static JsonObject toJsonObject(Map input) {
//         return new Gson().toJsonTree(input).getAsJsonObject();
//     }
// 
//     public static Map toHashMap(String input) {
//         return new Gson().fromJson(input, HashMap.class);
//     }
// 
//     public static Map toHashMap(JsonObject input) {
//         return new Gson().fromJson(input, HashMap.class);
//     }
// 
//     public static String prettyPrintString(Object input) {
//         return new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create().toJson(input);
//     }
// 
//     public static String prettyPrintString(JsonObject input) {
//         return new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create().toJson(input);
//     }
// }


import com.groupon.seleniumgridextras.utilities.FileIOUtility;
import com.groupon.seleniumgridextras.utilities.json.JsonParserWrapper;
import org.apache.commons.io.FileUtils;
import org.apache.log4j.Logger;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.HashMap;
import java.util.Map;
    if (this.configString.equals("")) {
      return false;
    } else {
      return true;
    }
  }

  public Map toHashMap() {
    if (hasContent()) {
      return this.parsedConfig;
    } else {
      return new HashMap();
    }
  }

  public void readConfigFile() {
    //Reason to use the "" instead of checking if the config already exists is because
    //if the file does exist but there is any formatting error, or parsing error, etc..
    //We assume file does not exist and overwrite it with good configs.
    String readString = "";
    try {
      readString = FileIOUtility.getAsString(this.filePath);
    } catch (FileNotFoundException error) {
      logger.info("File " + this.filePath + " does not exist, going to use default configs");
    }  catch (Exception error){
      error.printStackTrace();
      logger.warn(error.getMessage());
    }

    this.configString = readString;
// Path: SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/utilities/json/JsonParserWrapper.java
// public class JsonParserWrapper {
// 
//     public static List toList(String input) throws JsonSyntaxException {
//         return new Gson().fromJson(input, LinkedList.class);
//     }
// 
// 
//     public static JsonObject toJsonObject(Map input) {
//         return new Gson().toJsonTree(input).getAsJsonObject();
//     }
// 
//     public static Map toHashMap(String input) {
//         return new Gson().fromJson(input, HashMap.class);
//     }
// 
//     public static Map toHashMap(JsonObject input) {
//         return new Gson().fromJson(input, HashMap.class);
//     }
// 
//     public static String prettyPrintString(Object input) {
//         return new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create().toJson(input);
//     }
// 
//     public static String prettyPrintString(JsonObject input) {
//         return new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create().toJson(input);
//     }
// }


// Path: SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/config/ConfigFileReader.java
import com.groupon.seleniumgridextras.utilities.FileIOUtility;
import com.groupon.seleniumgridextras.utilities.json.JsonParserWrapper;
import org.apache.commons.io.FileUtils;
import org.apache.log4j.Logger;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.HashMap;
import java.util.Map;

    if (this.configString.equals("")) {
      return false;
    } else {
      return true;
    }
  }

  public Map toHashMap() {
    if (hasContent()) {
      return this.parsedConfig;
    } else {
      return new HashMap();
    }
  }

  public void readConfigFile() {
    //Reason to use the "" instead of checking if the config already exists is because
    //if the file does exist but there is any formatting error, or parsing error, etc..
    //We assume file does not exist and overwrite it with good configs.
    String readString = "";
    try {
      readString = FileIOUtility.getAsString(this.filePath);
    } catch (FileNotFoundException error) {
      logger.info("File " + this.filePath + " does not exist, going to use default configs");
    }  catch (Exception error){
      error.printStackTrace();
      logger.warn(error.getMessage());
    }

    this.configString = readString;
    this.parsedConfig = JsonParserWrapper.toHashMap(this.configString);