equivalent-exchange-3/common/com/pahimar/ee3/api/StackValueMapping.java

36 lines
1,009 B
Java
Raw Normal View History

2013-11-21 03:18:04 +01:00
package com.pahimar.ee3.api;
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
import com.pahimar.ee3.emc.EmcValue;
import com.pahimar.ee3.item.WrappedStack;
2013-11-21 03:18:04 +01:00
public class StackValueMapping {
private static Gson gsonSerializer = new Gson();
public final WrappedStack customWrappedStack;
2013-11-21 03:18:04 +01:00
public final EmcValue emcValue;
public StackValueMapping(WrappedStack customWrappedStack, EmcValue emcValue) {
2013-11-21 03:18:04 +01:00
this.customWrappedStack = customWrappedStack;
this.emcValue = emcValue;
}
public static StackValueMapping createFromJson(String jsonStackValueMapping) {
try {
return (StackValueMapping) gsonSerializer.fromJson(jsonStackValueMapping, StackValueMapping.class);
}
catch (JsonSyntaxException exception) {
// TODO Log something regarding the failed parse
}
return null;
}
public String toJson() {
return gsonSerializer.toJson(this);
}
}