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

com.nflabs.zeppelin.zan.Meta Maven / Gradle / Ivy

There is a newer version: 0.3.3
Show newest version
package com.nflabs.zeppelin.zan;

import java.io.File;
import java.io.IOException;

import org.apache.commons.io.FileUtils;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

/**
 * A library information
 * @author moon
 *
 */
public class Meta {
	public String repository;
	public String branch;
	public String commit;
	
	public Meta(String repository, String branch, String commit) {
		super();
		this.repository = repository;
		this.branch = branch;
		this.commit = commit;
	}

	public void write(File file) throws IOException{
		Gson gson = new GsonBuilder().setPrettyPrinting().create();
		String json = gson.toJson(this);
		if(file.isFile()){
			file.delete();
		}
		FileUtils.writeStringToFile(file, json, false);
	}
	
	public static Meta createFromFile(File file) throws IOException{
		Gson gson = new GsonBuilder().setPrettyPrinting().create();
		String json = FileUtils.readFileToString(file);
		return gson.fromJson(json, Meta.class);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy