/** * Optionally tag the {@link JSONObject} with the {@link Class} of the other {@link Object}. * * @param obj whose {@link Class} should be tagged * @param jsonObject that should be tagged * @param isAddClassTag if this is {@code false}, no action will be performed * @return the {@code jsonObject} */ public static JSONObject addClassTag(Object obj, JSONObject jsonObject, boolean isAddClassTag) { return isAddClassTag ? addClassTag(obj, jsonObject) : jsonObject; }
@Override public JSONObject serialize(Platform platform) { // Enforce polymorph serialization. return JsonSerializables.addClassTag(platform, new JSONObject()); }
/** * Serialize the given {@link Object} using a specific {@link JsonSerializer}. * * @param obj the {@link Object} to serialize * @param isPolymorph in case a {@link JSONObject} is created, whether it should be tagged with the {@link Class} * of {@code serializable} * @param serializer the {@link JsonSerializer} * @return the serialization result */ public static <T> JSONObject serialize(T obj, boolean isPolymorph, JsonSerializer<T> serializer) { return addClassTag(obj, serializer.serialize(obj), isPolymorph); }