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;
|
2013-11-27 04:23:36 +01:00
|
|
|
import com.pahimar.ee3.item.WrappedStack;
|
2013-11-21 03:18:04 +01:00
|
|
|
|
|
|
|
public class StackValueMapping {
|
|
|
|
|
|
|
|
private static Gson gsonSerializer = new Gson();
|
|
|
|
|
2013-11-27 04:23:36 +01:00
|
|
|
public final WrappedStack customWrappedStack;
|
2013-11-21 03:18:04 +01:00
|
|
|
public final EmcValue emcValue;
|
|
|
|
|
2013-11-27 04:23:36 +01:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|