package org.ambraproject.rhino.view.user;

import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonSerializationContext;
import org.ambraproject.rhino.view.JsonOutputView;

public class UserIdView implements JsonOutputView {

  private final long userProfileId;

  public UserIdView(long userProfileId) {
    this.userProfileId = userProfileId;
  }

  @Override
  public JsonElement serialize(JsonSerializationContext context) {
    JsonObject serialized = new JsonObject();
    serialized.addProperty("userId", String.valueOf(userProfileId));
    return serialized;
  }

  @Override
  public boolean equals(Object o) {
    return (this == o) || ((o != null) && (getClass() == o.getClass())
        && (userProfileId == ((UserIdView) o).userProfileId));
  }

  @Override
  public int hashCode() {
    return Long.hashCode(userProfileId);
  }

}

@@ -208,16 +208,78 @@
 tView;%0A%0A
+/**%0A * Wrapper for an ID pointing into the user database.%0A */%0A
 public c
@@ -576,44 +576,473 @@
 ();%0A
+%0A
     
-serialized.addProperty(%22
+/*%0A     * Although the userProfileId's low-level representation is a long integer, in the API we expose this essentially%0A     * non-numeric value as a string. This serves two purposes. First, it is general future-proofing in case we ever%0A     * want to change the ID scheme to allow arbitrary strings. Second, it helps prevent loss of precision in case the%0A     * client deserializes it to a floating-point value or smaller integer.%0A     */%0A    String 
 userId
-%22,
+ =
  Str
@@ -1063,24 +1063,70 @@
 erProfileId)
+;%0A%0A    serialized.addProperty(%22userId%22, userId
 );%0A    retur

Add Javadoc to UserIdView