package org.ambraproject.rhino.view;

import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import org.ambraproject.models.UserProfile;

import java.lang.reflect.Type;

public enum UserProfileSerializer implements JsonSerializer<UserProfile> {
  INSTANCE;

  @Override
  public JsonElement serialize(UserProfile src, Type typeOfSrc, JsonSerializationContext context) {
    long id = src.getID();
    String idString = Long.toString(id); // prevent loss of precision, in case JSON is deserialized to floating point
    JsonObject view = new JsonObject();
    view.addProperty("nedId", idString);
    return view;
  }
}

@@ -106,46 +106,8 @@
 ct;%0A
-import com.google.gson.JsonPrimitive;%0A
 impo
@@ -151,16 +151,16 @@
 ontext;%0A
+
 import c
@@ -267,16 +267,339 @@
 .Type;%0A%0A
+/**%0A * Suppresses all data from the user profile table except for the primary key, which is represented as the NED ID.%0A * %3Cp%3E%0A * This will prevent any downstream service from consuming any data represented by the %7B@link UserProfile%7D model, in%0A * preparation to move that data from this stack's persistence tier to NED.%0A */%0A
 public e

Add comment