@Override public JsonElement serialize(SparkSpecification src, Type typeOfSrc, JsonSerializationContext context) { JsonObject jsonObj = new JsonObject(); jsonObj.add("className", new JsonPrimitive(src.getClassName())); jsonObj.add("name", new JsonPrimitive(src.getName())); jsonObj.add("description", new JsonPrimitive(src.getDescription())); jsonObj.add("plugins", serializeMap(src.getPlugins(), context, Plugin.class)); if (src.getMainClassName() != null) { jsonObj.add("mainClassName", new JsonPrimitive(src.getMainClassName())); } jsonObj.add("datasets", serializeSet(src.getDatasets(), context, String.class)); jsonObj.add("properties", serializeMap(src.getProperties(), context, String.class)); serializeResources(jsonObj, "client", context, src.getClientResources()); serializeResources(jsonObj, "driver", context, src.getDriverResources()); serializeResources(jsonObj, "executor", context, src.getExecutorResources()); jsonObj.add("handlers", serializeList(src.getHandlers(), context, SparkHttpServiceHandlerSpecification.class)); return jsonObj; }
@Override public JsonElement serialize(SparkSpecification src, Type typeOfSrc, JsonSerializationContext context) { JsonObject jsonObj = new JsonObject(); jsonObj.add("className", new JsonPrimitive(src.getClassName())); jsonObj.add("name", new JsonPrimitive(src.getName())); jsonObj.add("description", new JsonPrimitive(src.getDescription())); jsonObj.add("plugins", serializeMap(src.getPlugins(), context, Plugin.class)); if (src.getMainClassName() != null) { jsonObj.add("mainClassName", new JsonPrimitive(src.getMainClassName())); } jsonObj.add("datasets", serializeSet(src.getDatasets(), context, String.class)); jsonObj.add("properties", serializeMap(src.getProperties(), context, String.class)); serializeResources(jsonObj, "client", context, src.getClientResources()); serializeResources(jsonObj, "driver", context, src.getDriverResources()); serializeResources(jsonObj, "executor", context, src.getExecutorResources()); jsonObj.add("handlers", serializeList(src.getHandlers(), context, SparkHttpServiceHandlerSpecification.class)); return jsonObj; }