Greenhouses/src/main/java/world/bentobox/greenhouses/data/adapters/BiomeRecipeAdapter.java

30 lines
802 B
Java
Raw Normal View History

2019-01-30 17:09:55 +01:00
package world.bentobox.greenhouses.data.adapters;
import world.bentobox.bentobox.database.objects.adapters.AdapterInterface;
import world.bentobox.greenhouses.greenhouse.BiomeRecipe;
import world.bentobox.greenhouses.managers.RecipeManager;
/**
* @author tastybento
*
*/
2019-01-30 17:09:55 +01:00
public class BiomeRecipeAdapter implements AdapterInterface<BiomeRecipe, String> {
@Override
public BiomeRecipe deserialize(Object object) {
2019-01-31 00:30:24 +01:00
if (object instanceof String && ((String)object).equals("null")) {
return null;
}
return RecipeManager.getBiomeRecipies((String)object).orElse(null);
}
@Override
public String serialize(Object object) {
2019-01-31 00:30:24 +01:00
if (object == null) {
return "null";
}
return ((BiomeRecipe)object).getName();
}
}