Esempio n. 1
0
    @Override
    public JsonElement serialize(
        Data<T> data, Type type, JsonSerializationContext jsonSerializationContext) {
      Set<String> workers = new HashSet<String>();
      for (Worker<T> worker : data.getWorkers()) {
        workers.add(worker.getName());
      }
      JsonElement jworkers = jsonSerializationContext.serialize(workers);
      JsonElement objects = jsonSerializationContext.serialize(data.getObjects());
      JsonElement goldObjects = jsonSerializationContext.serialize(data.getGoldObjects());
      JsonElement evaluationObjects =
          jsonSerializationContext.serialize(data.getEvaluationObjects());
      JsonElement assigns = jsonSerializationContext.serialize(data.getAssigns());

      JsonObject je = new JsonObject();
      je.add("workers", jworkers);
      je.add("objects", objects);
      je.add("goldObjects", goldObjects);
      je.add("evaluationObjects", evaluationObjects);
      je.add("assigns", assigns);

      return je;
    }
Esempio n. 2
0
 @Override
 public JsonElement serialize(Worker<T> w, Type type, JsonSerializationContext ctx) {
   return new JsonPrimitive(w.getName());
 }