/**
  * Convert a cursor object from database to a user object
  *
  * @param cursor the result of a query to the database
  * @return the user object
  */
 public static Notification parse(Cursor cursor) {
   Notification notification = new Notification();
   notification.setId(cursor.getInt(0));
   notification.setUserFrom(cursor.getString(0));
   notification.setUserTo(User.parse(cursor));
   notification.setMessage(cursor.getString(1));
   notification.setType(TYPE.fromValue(cursor.getInt(0)));
   return notification;
 }
  /**
   * Convert a json object from rest service to a user object
   *
   * @param token the token got by the rest service
   * @return the user object
   */
  public static Notification parse(JSONObject token) {
    try {
      Notification notification = new Notification();
      notification.setId(token.getInt("id"));
      notification.setUserFrom(token.getString("source"));
      notification.setMessage(token.getString("content"));
      notification.setType(stringToType(token.getString("type")));
      notification.setRead(token.getBoolean("read"));
      return notification;

    } catch (JSONException e) {
      e.printStackTrace();
      return null;
    }
  }