equivalent-exchange-3/src/main/java/com/pahimar/ee3/api/RecipeMapping.java

38 lines
1 KiB
Java
Raw Normal View History

2013-11-23 13:40:44 +01:00
package com.pahimar.ee3.api;
import java.util.List;
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
import com.pahimar.ee3.item.WrappedStack;
2013-11-23 13:40:44 +01:00
public class RecipeMapping
{
private static Gson gsonSerializer = new Gson();
public final WrappedStack outputWrappedStack;
public final List<WrappedStack> inputWrappedStacks;
2013-11-23 13:40:44 +01:00
public RecipeMapping(WrappedStack outputWrappedStack, List<WrappedStack> inputWrappedStacks) {
2013-11-23 13:40:44 +01:00
this.outputWrappedStack = outputWrappedStack;
this.inputWrappedStacks = inputWrappedStacks;
}
public static RecipeMapping createFromJson(String jsonRecipeMapping) {
try {
return (RecipeMapping) gsonSerializer.fromJson(jsonRecipeMapping, RecipeMapping.class);
}
catch (JsonSyntaxException exception) {
exception.printStackTrace();
// TODO Log something regarding the failed parse
}
return null;
}
public String toJson() {
return gsonSerializer.toJson(this);
}
}