@SuppressWarnings("unchecked")
 public static <T extends JsonElement> T deepCopy(T from) {
   if (from == null) {
     throw new IllegalArgumentException("from must not be null");
   }
   if (from instanceof JsonObject) {
     return (T) deepCopyObj((JsonObject) from);
   }
   if (from instanceof JsonArray) {
     return (T) deepCopyArr((JsonArray) from);
   }
   if (from instanceof JsonNull) {
     return (T) JsonNull.INSTANCE;
   }
   if (from instanceof JsonPrimitive) {
     // Nulls and primitives are immutable
     return from;
   }
   throw new AssertionError("Unknown element type " + from.getClass().getName());
 }
Example #2
0
 public static <T extends ValidatedJob> T hygiene(T job) {
   job.source = null;
   job.validation = null;
   return job;
 }
Example #3
0
 public JsonElement serialize(T object, Type interfaceType, JsonSerializationContext context) {
   final JsonObject wrapper = new JsonObject();
   wrapper.addProperty("type", object.getClass().getName());
   wrapper.add("data", context.serialize(object));
   return wrapper;
 }
Example #4
0
 /** Hygienic method to prevent accidental capture of non desired values. */
 public static <T extends FrameJob> T hygiene(T job) {
   job.source = null;
   return job;
 }