package org.silverpeas.mobile.shared.dto.media;

import static org.fusesource.restygwt.client.AbstractJsonEncoderDecoder.*;

public class MediaDTO_Generated_JsonEncoderDecoder_ extends org.fusesource.restygwt.client.AbstractJsonEncoderDecoder<org.silverpeas.mobile.shared.dto.media.MediaDTO> {
  
  public static final MediaDTO_Generated_JsonEncoderDecoder_ INSTANCE = new MediaDTO_Generated_JsonEncoderDecoder_();
  
  public com.google.gwt.json.client.JSONValue encode(org.silverpeas.mobile.shared.dto.media.MediaDTO value) {
    if( value==null ) {
      return getNullType();
    }
    if(value.getClass().getName().equals("org.silverpeas.mobile.shared.dto.media.MediaDTO"))
    {
      return encodeMediaDTO1302088388(value);
    }
    if(value.getClass().getName().equals("org.silverpeas.mobile.shared.dto.media.PhotoDTO"))
    {
      return encodePhotoDTO1192842756(value);
    }
    if(value.getClass().getName().equals("org.silverpeas.mobile.shared.dto.media.SoundDTO"))
    {
      return encodeSoundDTO1717624441(value);
    }
    if(value.getClass().getName().equals("org.silverpeas.mobile.shared.dto.media.VideoDTO"))
    {
      return encodeVideoDTO1729943902(value);
    }
    if(value.getClass().getName().equals("org.silverpeas.mobile.shared.dto.media.VideoStreamingDTO"))
    {
      return encodeVideoStreamingDTO1224307987(value);
    }
    return null;
  }
  
  private com.google.gwt.json.client.JSONValue encodeMediaDTO1302088388( org.silverpeas.mobile.shared.dto.media.MediaDTO value) {
    com.google.gwt.json.client.JSONObject rc = new com.google.gwt.json.client.JSONObject();
    com.google.gwt.json.client.JSONValue className=STRING.encode("MediaDTO");
    if( className!=null ) { 
      rc.put("@class", className);
    }
    org.silverpeas.mobile.shared.dto.media.MediaDTO parseValue = (org.silverpeas.mobile.shared.dto.media.MediaDTO)value;
    isNotNullValuePut(BOOLEAN.encode(parseValue.getDownload()), rc, "download");
    isNotNullValuePut(STRING.encode(parseValue.getTitle()), rc, "title");
    isNotNullValuePut(STRING.encode(parseValue.getName()), rc, "name");
    isNotNullValuePut(STRING.encode(parseValue.getUpdateDate()), rc, "updateDate");
    isNotNullValuePut(STRING.encode(parseValue.getUpdater()), rc, "updater");
    isNotNullValuePut(STRING.encode(parseValue.getCreator()), rc, "creator");
    isNotNullValuePut(STRING.encode(parseValue.getCreationDate()), rc, "creationDate");
    isNotNullValuePut(INT.encode(parseValue.getCommentsNumber()), rc, "commentsNumber");
    isNotNullValuePut(STRING.encode(parseValue.getInstance()), rc, "instance");
    isNotNullValuePut(STRING.encode(parseValue.getMimeType()), rc, "mimeType");
    isNotNullValuePut(LONG.encode(parseValue.getSize()), rc, "size");
    isNotNullValuePut(STRING.encode(parseValue.getId()), rc, "id");
    return rc;
  }
  
  private com.google.gwt.json.client.JSONValue encodePhotoDTO1192842756( org.silverpeas.mobile.shared.dto.media.MediaDTO value) {
    com.google.gwt.json.client.JSONObject rc = new com.google.gwt.json.client.JSONObject();
    com.google.gwt.json.client.JSONValue className=STRING.encode("PhotoDTO");
    if( className!=null ) { 
      rc.put("@class", className);
    }
    org.silverpeas.mobile.shared.dto.media.PhotoDTO parseValue = (org.silverpeas.mobile.shared.dto.media.PhotoDTO)value;
    isNotNullValuePut(STRING.encode(parseValue.getDataPhoto()), rc, "dataPhoto");
    isNotNullValuePut(STRING.encode(parseValue.getFormat()), rc, "format");
    isNotNullValuePut(INT.encode(parseValue.getSizeH()), rc, "sizeH");
    isNotNullValuePut(INT.encode(parseValue.getSizeL()), rc, "sizeL");
    isNotNullValuePut(BOOLEAN.encode(parseValue.getDownload()), rc, "download");
    isNotNullValuePut(STRING.encode(parseValue.getTitle()), rc, "title");
    isNotNullValuePut(STRING.encode(parseValue.getName()), rc, "name");
    isNotNullValuePut(STRING.encode(parseValue.getUpdateDate()), rc, "updateDate");
    isNotNullValuePut(STRING.encode(parseValue.getUpdater()), rc, "updater");
    isNotNullValuePut(STRING.encode(parseValue.getCreator()), rc, "creator");
    isNotNullValuePut(STRING.encode(parseValue.getCreationDate()), rc, "creationDate");
    isNotNullValuePut(INT.encode(parseValue.getCommentsNumber()), rc, "commentsNumber");
    isNotNullValuePut(STRING.encode(parseValue.getInstance()), rc, "instance");
    isNotNullValuePut(STRING.encode(parseValue.getMimeType()), rc, "mimeType");
    isNotNullValuePut(LONG.encode(parseValue.getSize()), rc, "size");
    isNotNullValuePut(STRING.encode(parseValue.getId()), rc, "id");
    return rc;
  }
  
  private com.google.gwt.json.client.JSONValue encodeSoundDTO1717624441( org.silverpeas.mobile.shared.dto.media.MediaDTO value) {
    com.google.gwt.json.client.JSONObject rc = new com.google.gwt.json.client.JSONObject();
    com.google.gwt.json.client.JSONValue className=STRING.encode("SoundDTO");
    if( className!=null ) { 
      rc.put("@class", className);
    }
    org.silverpeas.mobile.shared.dto.media.SoundDTO parseValue = (org.silverpeas.mobile.shared.dto.media.SoundDTO)value;
    isNotNullValuePut(STRING.encode(parseValue.getDuration()), rc, "duration");
    isNotNullValuePut(BOOLEAN.encode(parseValue.getDownload()), rc, "download");
    isNotNullValuePut(STRING.encode(parseValue.getTitle()), rc, "title");
    isNotNullValuePut(STRING.encode(parseValue.getName()), rc, "name");
    isNotNullValuePut(STRING.encode(parseValue.getUpdateDate()), rc, "updateDate");
    isNotNullValuePut(STRING.encode(parseValue.getUpdater()), rc, "updater");
    isNotNullValuePut(STRING.encode(parseValue.getCreator()), rc, "creator");
    isNotNullValuePut(STRING.encode(parseValue.getCreationDate()), rc, "creationDate");
    isNotNullValuePut(INT.encode(parseValue.getCommentsNumber()), rc, "commentsNumber");
    isNotNullValuePut(STRING.encode(parseValue.getInstance()), rc, "instance");
    isNotNullValuePut(STRING.encode(parseValue.getMimeType()), rc, "mimeType");
    isNotNullValuePut(LONG.encode(parseValue.getSize()), rc, "size");
    isNotNullValuePut(STRING.encode(parseValue.getId()), rc, "id");
    return rc;
  }
  
  private com.google.gwt.json.client.JSONValue encodeVideoDTO1729943902( org.silverpeas.mobile.shared.dto.media.MediaDTO value) {
    com.google.gwt.json.client.JSONObject rc = new com.google.gwt.json.client.JSONObject();
    com.google.gwt.json.client.JSONValue className=STRING.encode("VideoDTO");
    if( className!=null ) { 
      rc.put("@class", className);
    }
    org.silverpeas.mobile.shared.dto.media.VideoDTO parseValue = (org.silverpeas.mobile.shared.dto.media.VideoDTO)value;
    isNotNullValuePut(STRING.encode(parseValue.getDuration()), rc, "duration");
    isNotNullValuePut(STRING.encode(parseValue.getDataPoster()), rc, "dataPoster");
    isNotNullValuePut(BOOLEAN.encode(parseValue.getDownload()), rc, "download");
    isNotNullValuePut(STRING.encode(parseValue.getTitle()), rc, "title");
    isNotNullValuePut(STRING.encode(parseValue.getName()), rc, "name");
    isNotNullValuePut(STRING.encode(parseValue.getUpdateDate()), rc, "updateDate");
    isNotNullValuePut(STRING.encode(parseValue.getUpdater()), rc, "updater");
    isNotNullValuePut(STRING.encode(parseValue.getCreator()), rc, "creator");
    isNotNullValuePut(STRING.encode(parseValue.getCreationDate()), rc, "creationDate");
    isNotNullValuePut(INT.encode(parseValue.getCommentsNumber()), rc, "commentsNumber");
    isNotNullValuePut(STRING.encode(parseValue.getInstance()), rc, "instance");
    isNotNullValuePut(STRING.encode(parseValue.getMimeType()), rc, "mimeType");
    isNotNullValuePut(LONG.encode(parseValue.getSize()), rc, "size");
    isNotNullValuePut(STRING.encode(parseValue.getId()), rc, "id");
    return rc;
  }
  
  private com.google.gwt.json.client.JSONValue encodeVideoStreamingDTO1224307987( org.silverpeas.mobile.shared.dto.media.MediaDTO value) {
    com.google.gwt.json.client.JSONObject rc = new com.google.gwt.json.client.JSONObject();
    com.google.gwt.json.client.JSONValue className=STRING.encode("VideoStreamingDTO");
    if( className!=null ) { 
      rc.put("@class", className);
    }
    org.silverpeas.mobile.shared.dto.media.VideoStreamingDTO parseValue = (org.silverpeas.mobile.shared.dto.media.VideoStreamingDTO)value;
    isNotNullValuePut(STRING.encode(parseValue.getDuration()), rc, "duration");
    isNotNullValuePut(STRING.encode(parseValue.getUrl()), rc, "url");
    isNotNullValuePut(STRING.encode(parseValue.getUrlPoster()), rc, "urlPoster");
    isNotNullValuePut(BOOLEAN.encode(parseValue.getDownload()), rc, "download");
    isNotNullValuePut(STRING.encode(parseValue.getTitle()), rc, "title");
    isNotNullValuePut(STRING.encode(parseValue.getName()), rc, "name");
    isNotNullValuePut(STRING.encode(parseValue.getUpdateDate()), rc, "updateDate");
    isNotNullValuePut(STRING.encode(parseValue.getUpdater()), rc, "updater");
    isNotNullValuePut(STRING.encode(parseValue.getCreator()), rc, "creator");
    isNotNullValuePut(STRING.encode(parseValue.getCreationDate()), rc, "creationDate");
    isNotNullValuePut(INT.encode(parseValue.getCommentsNumber()), rc, "commentsNumber");
    isNotNullValuePut(STRING.encode(parseValue.getInstance()), rc, "instance");
    isNotNullValuePut(STRING.encode(parseValue.getMimeType()), rc, "mimeType");
    isNotNullValuePut(LONG.encode(parseValue.getSize()), rc, "size");
    isNotNullValuePut(STRING.encode(parseValue.getId()), rc, "id");
    return rc;
  }
  
  public org.silverpeas.mobile.shared.dto.media.MediaDTO decode(com.google.gwt.json.client.JSONValue value) {
    if( value == null || value.isNull()!=null ) {
      return null;
    }
    com.google.gwt.json.client.JSONObject object = toObject(value);
    String sourceName = STRING.decode(object.get("@class"));
    if(sourceName == null || sourceName.equals("MediaDTO"))
    {
      return decodeMediaDTO1302088388(object);
    }
    if("PhotoDTO".equals(sourceName))
    {
      return decodePhotoDTO1192842756(object);
    }
    if("SoundDTO".equals(sourceName))
    {
      return decodeSoundDTO1717624441(object);
    }
    if("VideoDTO".equals(sourceName))
    {
      return decodeVideoDTO1729943902(object);
    }
    if("VideoStreamingDTO".equals(sourceName))
    {
      return decodeVideoStreamingDTO1224307987(object);
    }
    return null;
  }
  
  private org.silverpeas.mobile.shared.dto.media.MediaDTO decodeMediaDTO1302088388(com.google.gwt.json.client.JSONObject object) {
    org.silverpeas.mobile.shared.dto.media.MediaDTO rc = new org.silverpeas.mobile.shared.dto.media.MediaDTO();
    rc.setDownload(getValueToSet(BOOLEAN.decode(object.get("download")), false));
    rc.setTitle(getValueToSet(STRING.decode(object.get("title")), null));
    rc.setName(getValueToSet(STRING.decode(object.get("name")), null));
    rc.setUpdateDate(getValueToSet(STRING.decode(object.get("updateDate")), null));
    rc.setUpdater(getValueToSet(STRING.decode(object.get("updater")), null));
    rc.setCreator(getValueToSet(STRING.decode(object.get("creator")), null));
    rc.setCreationDate(getValueToSet(STRING.decode(object.get("creationDate")), null));
    rc.setCommentsNumber(getValueToSet(INT.decode(object.get("commentsNumber")), 0));
    rc.setInstance(getValueToSet(STRING.decode(object.get("instance")), null));
    rc.setMimeType(getValueToSet(STRING.decode(object.get("mimeType")), null));
    rc.setSize(getValueToSet(LONG.decode(object.get("size")), 0L));
    rc.setId(getValueToSet(STRING.decode(object.get("id")), null));
    return rc;
  }
  
  private org.silverpeas.mobile.shared.dto.media.MediaDTO decodePhotoDTO1192842756(com.google.gwt.json.client.JSONObject object) {
    org.silverpeas.mobile.shared.dto.media.PhotoDTO rc = new org.silverpeas.mobile.shared.dto.media.PhotoDTO();
    rc.setDataPhoto(getValueToSet(STRING.decode(object.get("dataPhoto")), null));
    rc.setFormat(getValueToSet(STRING.decode(object.get("format")), null));
    rc.setSizeH(getValueToSet(INT.decode(object.get("sizeH")), 0));
    rc.setSizeL(getValueToSet(INT.decode(object.get("sizeL")), 0));
    rc.setDownload(getValueToSet(BOOLEAN.decode(object.get("download")), false));
    rc.setTitle(getValueToSet(STRING.decode(object.get("title")), null));
    rc.setName(getValueToSet(STRING.decode(object.get("name")), null));
    rc.setUpdateDate(getValueToSet(STRING.decode(object.get("updateDate")), null));
    rc.setUpdater(getValueToSet(STRING.decode(object.get("updater")), null));
    rc.setCreator(getValueToSet(STRING.decode(object.get("creator")), null));
    rc.setCreationDate(getValueToSet(STRING.decode(object.get("creationDate")), null));
    rc.setCommentsNumber(getValueToSet(INT.decode(object.get("commentsNumber")), 0));
    rc.setInstance(getValueToSet(STRING.decode(object.get("instance")), null));
    rc.setMimeType(getValueToSet(STRING.decode(object.get("mimeType")), null));
    rc.setSize(getValueToSet(LONG.decode(object.get("size")), 0L));
    rc.setId(getValueToSet(STRING.decode(object.get("id")), null));
    return rc;
  }
  
  private org.silverpeas.mobile.shared.dto.media.MediaDTO decodeSoundDTO1717624441(com.google.gwt.json.client.JSONObject object) {
    org.silverpeas.mobile.shared.dto.media.SoundDTO rc = new org.silverpeas.mobile.shared.dto.media.SoundDTO();
    rc.setDuration(getValueToSet(STRING.decode(object.get("duration")), null));
    rc.setDownload(getValueToSet(BOOLEAN.decode(object.get("download")), false));
    rc.setTitle(getValueToSet(STRING.decode(object.get("title")), null));
    rc.setName(getValueToSet(STRING.decode(object.get("name")), null));
    rc.setUpdateDate(getValueToSet(STRING.decode(object.get("updateDate")), null));
    rc.setUpdater(getValueToSet(STRING.decode(object.get("updater")), null));
    rc.setCreator(getValueToSet(STRING.decode(object.get("creator")), null));
    rc.setCreationDate(getValueToSet(STRING.decode(object.get("creationDate")), null));
    rc.setCommentsNumber(getValueToSet(INT.decode(object.get("commentsNumber")), 0));
    rc.setInstance(getValueToSet(STRING.decode(object.get("instance")), null));
    rc.setMimeType(getValueToSet(STRING.decode(object.get("mimeType")), null));
    rc.setSize(getValueToSet(LONG.decode(object.get("size")), 0L));
    rc.setId(getValueToSet(STRING.decode(object.get("id")), null));
    return rc;
  }
  
  private org.silverpeas.mobile.shared.dto.media.MediaDTO decodeVideoDTO1729943902(com.google.gwt.json.client.JSONObject object) {
    org.silverpeas.mobile.shared.dto.media.VideoDTO rc = new org.silverpeas.mobile.shared.dto.media.VideoDTO();
    rc.setDuration(getValueToSet(STRING.decode(object.get("duration")), null));
    rc.setDataPoster(getValueToSet(STRING.decode(object.get("dataPoster")), null));
    rc.setDownload(getValueToSet(BOOLEAN.decode(object.get("download")), false));
    rc.setTitle(getValueToSet(STRING.decode(object.get("title")), null));
    rc.setName(getValueToSet(STRING.decode(object.get("name")), null));
    rc.setUpdateDate(getValueToSet(STRING.decode(object.get("updateDate")), null));
    rc.setUpdater(getValueToSet(STRING.decode(object.get("updater")), null));
    rc.setCreator(getValueToSet(STRING.decode(object.get("creator")), null));
    rc.setCreationDate(getValueToSet(STRING.decode(object.get("creationDate")), null));
    rc.setCommentsNumber(getValueToSet(INT.decode(object.get("commentsNumber")), 0));
    rc.setInstance(getValueToSet(STRING.decode(object.get("instance")), null));
    rc.setMimeType(getValueToSet(STRING.decode(object.get("mimeType")), null));
    rc.setSize(getValueToSet(LONG.decode(object.get("size")), 0L));
    rc.setId(getValueToSet(STRING.decode(object.get("id")), null));
    return rc;
  }
  
  private org.silverpeas.mobile.shared.dto.media.MediaDTO decodeVideoStreamingDTO1224307987(com.google.gwt.json.client.JSONObject object) {
    org.silverpeas.mobile.shared.dto.media.VideoStreamingDTO rc = new org.silverpeas.mobile.shared.dto.media.VideoStreamingDTO();
    rc.setDuration(getValueToSet(STRING.decode(object.get("duration")), null));
    rc.setUrl(getValueToSet(STRING.decode(object.get("url")), null));
    rc.setUrlPoster(getValueToSet(STRING.decode(object.get("urlPoster")), null));
    rc.setDownload(getValueToSet(BOOLEAN.decode(object.get("download")), false));
    rc.setTitle(getValueToSet(STRING.decode(object.get("title")), null));
    rc.setName(getValueToSet(STRING.decode(object.get("name")), null));
    rc.setUpdateDate(getValueToSet(STRING.decode(object.get("updateDate")), null));
    rc.setUpdater(getValueToSet(STRING.decode(object.get("updater")), null));
    rc.setCreator(getValueToSet(STRING.decode(object.get("creator")), null));
    rc.setCreationDate(getValueToSet(STRING.decode(object.get("creationDate")), null));
    rc.setCommentsNumber(getValueToSet(INT.decode(object.get("commentsNumber")), 0));
    rc.setInstance(getValueToSet(STRING.decode(object.get("instance")), null));
    rc.setMimeType(getValueToSet(STRING.decode(object.get("mimeType")), null));
    rc.setSize(getValueToSet(LONG.decode(object.get("size")), 0L));
    rc.setId(getValueToSet(STRING.decode(object.get("id")), null));
    return rc;
  }
  
}
