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

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

public class ClassifiedDTO_Generated_JsonEncoderDecoder_ extends org.fusesource.restygwt.client.AbstractJsonEncoderDecoder<org.silverpeas.mobile.shared.dto.classifieds.ClassifiedDTO> {
  
  public static final ClassifiedDTO_Generated_JsonEncoderDecoder_ INSTANCE = new ClassifiedDTO_Generated_JsonEncoderDecoder_();
  
  public com.google.gwt.json.client.JSONValue encode(org.silverpeas.mobile.shared.dto.classifieds.ClassifiedDTO value) {
    if( value==null ) {
      return getNullType();
    }
      return encodeClassifiedDTO122472821(value);
    }
    
    private com.google.gwt.json.client.JSONValue encodeClassifiedDTO122472821( org.silverpeas.mobile.shared.dto.classifieds.ClassifiedDTO value) {
      com.google.gwt.json.client.JSONObject rc = new com.google.gwt.json.client.JSONObject();
      com.google.gwt.json.client.JSONValue className=STRING.encode("ClassifiedDTO");
      if( className!=null ) { 
        rc.put("@class", className);
      }
      org.silverpeas.mobile.shared.dto.classifieds.ClassifiedDTO parseValue = (org.silverpeas.mobile.shared.dto.classifieds.ClassifiedDTO)value;
      isNotNullValuePut(STRING.encode(parseValue.getTitle()), rc, "title");
      isNotNullValuePut(STRING.encode(parseValue.getDescription()), rc, "description");
      isNotNullValuePut(STRING.encode(parseValue.getPrice()), rc, "price");
      isNotNullValuePut(STRING.encode(parseValue.getType()), rc, "type");
      isNotNullValuePut(STRING.encode(parseValue.getCategory()), rc, "category");
      isNotNullValuePut(toJSON(parseValue.getPictures(), STRING), rc, "pictures");
      isNotNullValuePut(STRING.encode(parseValue.getCreatorName()), rc, "creatorName");
      isNotNullValuePut(STRING.encode(parseValue.getCreatorId()), rc, "creatorId");
      isNotNullValuePut(STRING.encode(parseValue.getCreationDate()), rc, "creationDate");
      isNotNullValuePut(STRING.encode(parseValue.getUpdateDate()), rc, "updateDate");
      isNotNullValuePut(INT.encode(parseValue.getCommentsNumber()), rc, "commentsNumber");
      isNotNullValuePut(toJSON(parseValue.getFields(), org.silverpeas.mobile.shared.dto.FormFieldDTO_Generated_JsonEncoderDecoder_.INSTANCE), rc, "fields");
      isNotNullValuePut(BOOLEAN.encode(parseValue.getShowPrice()), rc, "showPrice");
      isNotNullValuePut(STRING.encode(parseValue.getId()), rc, "id");
      return rc;
    }
    
    public org.silverpeas.mobile.shared.dto.classifieds.ClassifiedDTO 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);
        return decodeClassifiedDTO122472821(object);
      }
      
      private org.silverpeas.mobile.shared.dto.classifieds.ClassifiedDTO decodeClassifiedDTO122472821(com.google.gwt.json.client.JSONObject object) {
        org.silverpeas.mobile.shared.dto.classifieds.ClassifiedDTO rc = new org.silverpeas.mobile.shared.dto.classifieds.ClassifiedDTO();
        rc.setTitle(getValueToSet(STRING.decode(object.get("title")), null));
        rc.setDescription(getValueToSet(STRING.decode(object.get("description")), null));
        rc.setPrice(getValueToSet(STRING.decode(object.get("price")), null));
        rc.setType(getValueToSet(STRING.decode(object.get("type")), null));
        rc.setCategory(getValueToSet(STRING.decode(object.get("category")), null));
        rc.setPictures(getValueToSet(toList(object.get("pictures"), STRING), null));
        rc.setCreatorName(getValueToSet(STRING.decode(object.get("creatorName")), null));
        rc.setCreatorId(getValueToSet(STRING.decode(object.get("creatorId")), null));
        rc.setCreationDate(getValueToSet(STRING.decode(object.get("creationDate")), null));
        rc.setUpdateDate(getValueToSet(STRING.decode(object.get("updateDate")), null));
        rc.setCommentsNumber(getValueToSet(INT.decode(object.get("commentsNumber")), 0));
        rc.setFields(getValueToSet(toList(object.get("fields"), org.silverpeas.mobile.shared.dto.FormFieldDTO_Generated_JsonEncoderDecoder_.INSTANCE), null));
        rc.setShowPrice(getValueToSet(BOOLEAN.decode(object.get("showPrice")), false));
        rc.setId(getValueToSet(STRING.decode(object.get("id")), null));
        return rc;
      }
      
    }
