Package com.jverrecchia.initializr.builder.modules

Source Code of com.jverrecchia.initializr.builder.modules.ModuleReader

package com.jverrecchia.initializr.builder.modules;

import java.io.IOException;

import com.google.gson.Gson;
import com.jverrecchia.initializr.builder.Utils;
import com.jverrecchia.initializr.builder.errors.ModuleNotFoundException;

public class ModuleReader {

  public static Module readModuleJson(String moduleName) throws ModuleNotFoundException{
      String filepath = "builder/modules/" + moduleName + "/" + moduleName + ".json";
    Gson gson = new Gson();
   
    String jsonString = null;
    try {
      jsonString = Utils.readFileAsString(filepath);
    } catch (IOException e) {
      throw new ModuleNotFoundException(moduleName);
    }
   
    return gson.fromJson(jsonString, Module.class);
  }
 
}
TOP

Related Classes of com.jverrecchia.initializr.builder.modules.ModuleReader

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.