public static void transferFireworkEffectMeta( FireworkEffectMeta meta, JsonObject json, boolean meta2json) { if (meta2json) { if (!meta.hasEffect()) return; json.add(FIREWORK_EFFECT, FireworkEffectAdapter.toJson(meta.getEffect())); } else { JsonElement element = json.get(FIREWORK_EFFECT); if (element == null) return; meta.setEffect(FireworkEffectAdapter.fromJson(element)); } }
public static List<FireworkEffect> convertFireworkEffectList(JsonElement jsonElement) { if (jsonElement == null) return null; if (!jsonElement.isJsonArray()) return null; JsonArray array = jsonElement.getAsJsonArray(); List<FireworkEffect> ret = new ArrayList<FireworkEffect>(); Iterator<JsonElement> iter = array.iterator(); while (iter.hasNext()) { FireworkEffect fe = FireworkEffectAdapter.fromJson(iter.next()); if (fe == null) continue; ret.add(fe); } return ret; }