com.oath.maven.plugin.freemarker.JsonPropertiesProvider Maven / Gradle / Ivy
// Copyright 2018, Oath Inc.
// Licensed under the terms of the Apache 2.0 license. See the LICENSE file in the project root for terms.
package com.oath.maven.plugin.freemarker;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import com.google.gson.stream.JsonReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Type;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.util.HashMap;
import java.util.Map;
import org.fugerit.java.core.cfg.ConfigRuntimeException;
public class JsonPropertiesProvider implements OutputGeneratorPropertiesProvider {
private final Gson gson;
private final Type stringObjectMap;
private final File dataDir;
private final File templateDir;
private final File outputDir;
private JsonPropertiesProvider(File dataDir, File templateDir, File outputDir) {
this.dataDir = dataDir;
this.templateDir = templateDir;
this.outputDir = outputDir;
gson = new GsonBuilder().setLenient().create();
stringObjectMap = new TypeToken