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

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

public class SilverpeasObjectDTO_Generated_JsonEncoderDecoder_ extends org.fusesource.restygwt.client.AbstractJsonEncoderDecoder<org.silverpeas.mobile.shared.dto.navigation.SilverpeasObjectDTO> {
  
  public static final SilverpeasObjectDTO_Generated_JsonEncoderDecoder_ INSTANCE = new SilverpeasObjectDTO_Generated_JsonEncoderDecoder_();
  
  public com.google.gwt.json.client.JSONValue encode(org.silverpeas.mobile.shared.dto.navigation.SilverpeasObjectDTO value) {
    if( value==null ) {
      return getNullType();
    }
    if(value.getClass().getName().equals("org.silverpeas.mobile.shared.dto.navigation.ApplicationInstanceDTO"))
    {
      return encodeApplicationInstanceDTO1269562259(value);
    }
    if(value.getClass().getName().equals("org.silverpeas.mobile.shared.dto.navigation.SpaceDTO"))
    {
      return encodeSpaceDTO1453419151(value);
    }
    return null;
  }
  
  private com.google.gwt.json.client.JSONValue encodeApplicationInstanceDTO1269562259( org.silverpeas.mobile.shared.dto.navigation.SilverpeasObjectDTO value) {
    com.google.gwt.json.client.JSONObject rc = new com.google.gwt.json.client.JSONObject();
    com.google.gwt.json.client.JSONValue className=STRING.encode("ApplicationInstanceDTO");
    if( className!=null ) { 
      rc.put("@class", className);
    }
    org.silverpeas.mobile.shared.dto.navigation.ApplicationInstanceDTO parseValue = (org.silverpeas.mobile.shared.dto.navigation.ApplicationInstanceDTO)value;
    isNotNullValuePut(STRING.encode(parseValue.getType()), rc, "type");
    isNotNullValuePut(org.silverpeas.mobile.shared.dto.RightDTO_Generated_JsonEncoderDecoder_.INSTANCE.encode(parseValue.getRights()), rc, "rights");
    isNotNullValuePut(BOOLEAN.encode(parseValue.getCommentable()), rc, "commentable");
    isNotNullValuePut(BOOLEAN.encode(parseValue.getNotifiable()), rc, "notifiable");
    isNotNullValuePut(BOOLEAN.encode(parseValue.getAbleToStoreContent()), rc, "ableToStoreContent");
    isNotNullValuePut(BOOLEAN.encode(parseValue.getWorkflow()), rc, "workflow");
    isNotNullValuePut(STRING.encode(parseValue.getExtraId()), rc, "extraId");
    isNotNullValuePut(INT.encode(parseValue.getFolderSharing()), rc, "folderSharing");
    isNotNullValuePut(INT.encode(parseValue.getPublicationSharing()), rc, "publicationSharing");
    isNotNullValuePut(INT.encode(parseValue.getFileSharing()), rc, "fileSharing");
    isNotNullValuePut(toJSON(parseValue.getParameters(), STRING, STRING, org.fusesource.restygwt.client.Json.Style.DEFAULT), rc, "parameters");
    isNotNullValuePut(BOOLEAN.encode(parseValue.getPersonnal()), rc, "personnal");
    isNotNullValuePut(STRING.encode(parseValue.getId()), rc, "id");
    isNotNullValuePut(STRING.encode(parseValue.getLabel()), rc, "label");
    isNotNullValuePut(INT.encode(parseValue.getOrderNum()), rc, "orderNum");
    return rc;
  }
  
  private com.google.gwt.json.client.JSONValue encodeSpaceDTO1453419151( org.silverpeas.mobile.shared.dto.navigation.SilverpeasObjectDTO value) {
    com.google.gwt.json.client.JSONObject rc = new com.google.gwt.json.client.JSONObject();
    com.google.gwt.json.client.JSONValue className=STRING.encode("SpaceDTO");
    if( className!=null ) { 
      rc.put("@class", className);
    }
    org.silverpeas.mobile.shared.dto.navigation.SpaceDTO parseValue = (org.silverpeas.mobile.shared.dto.navigation.SpaceDTO)value;
    isNotNullValuePut(BOOLEAN.encode(parseValue.isPersonal()), rc, "personal");
    isNotNullValuePut(INT.encode(parseValue.getHomePageType()), rc, "homePageType");
    isNotNullValuePut(STRING.encode(parseValue.getHomePageParameter()), rc, "homePageParameter");
    isNotNullValuePut(STRING.encode(parseValue.getId()), rc, "id");
    isNotNullValuePut(STRING.encode(parseValue.getLabel()), rc, "label");
    isNotNullValuePut(INT.encode(parseValue.getOrderNum()), rc, "orderNum");
    return rc;
  }
  
  public org.silverpeas.mobile.shared.dto.navigation.SilverpeasObjectDTO 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("ApplicationInstanceDTO".equals(sourceName))
    {
      return decodeApplicationInstanceDTO1269562259(object);
    }
    if("SpaceDTO".equals(sourceName))
    {
      return decodeSpaceDTO1453419151(object);
    }
    return null;
  }
  
  private org.silverpeas.mobile.shared.dto.navigation.SilverpeasObjectDTO decodeApplicationInstanceDTO1269562259(com.google.gwt.json.client.JSONObject object) {
    org.silverpeas.mobile.shared.dto.navigation.ApplicationInstanceDTO rc = new org.silverpeas.mobile.shared.dto.navigation.ApplicationInstanceDTO();
    rc.setType(getValueToSet(STRING.decode(object.get("type")), null));
    rc.setRights(getValueToSet(org.silverpeas.mobile.shared.dto.RightDTO_Generated_JsonEncoderDecoder_.INSTANCE.decode(object.get("rights")), null));
    rc.setCommentable(getValueToSet(BOOLEAN.decode(object.get("commentable")), false));
    rc.setNotifiable(getValueToSet(BOOLEAN.decode(object.get("notifiable")), false));
    rc.setAbleToStoreContent(getValueToSet(BOOLEAN.decode(object.get("ableToStoreContent")), false));
    rc.setWorkflow(getValueToSet(BOOLEAN.decode(object.get("workflow")), false));
    rc.setExtraId(getValueToSet(STRING.decode(object.get("extraId")), null));
    rc.setFolderSharing(getValueToSet(INT.decode(object.get("folderSharing")), 0));
    rc.setPublicationSharing(getValueToSet(INT.decode(object.get("publicationSharing")), 0));
    rc.setFileSharing(getValueToSet(INT.decode(object.get("fileSharing")), 0));
    rc.setParameters(getValueToSet(toMap(object.get("parameters"), STRING, STRING, org.fusesource.restygwt.client.Json.Style.DEFAULT), null));
    rc.setPersonnal(getValueToSet(BOOLEAN.decode(object.get("personnal")), false));
    rc.setId(getValueToSet(STRING.decode(object.get("id")), null));
    rc.setLabel(getValueToSet(STRING.decode(object.get("label")), null));
    rc.setOrderNum(getValueToSet(INT.decode(object.get("orderNum")), null));
    return rc;
  }
  
  private org.silverpeas.mobile.shared.dto.navigation.SilverpeasObjectDTO decodeSpaceDTO1453419151(com.google.gwt.json.client.JSONObject object) {
    org.silverpeas.mobile.shared.dto.navigation.SpaceDTO rc = new org.silverpeas.mobile.shared.dto.navigation.SpaceDTO();
    rc.setPersonal(getValueToSet(BOOLEAN.decode(object.get("personal")), false));
    rc.setHomePageType(getValueToSet(INT.decode(object.get("homePageType")), 0));
    rc.setHomePageParameter(getValueToSet(STRING.decode(object.get("homePageParameter")), null));
    rc.setId(getValueToSet(STRING.decode(object.get("id")), null));
    rc.setLabel(getValueToSet(STRING.decode(object.get("label")), null));
    rc.setOrderNum(getValueToSet(INT.decode(object.get("orderNum")), null));
    return rc;
  }
  
}
