Exemplo n.º 1
0
 @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());
 }
Exemplo n.º 2
0
 public static <T extends ValidatedJob> T hygiene(T job) {
   job.source = null;
   job.validation = null;
   return job;
 }
Exemplo n.º 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;
 }
Exemplo n.º 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;
 }