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

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

public class ClassifiedsDTO_Generated_JsonEncoderDecoder_ extends org.fusesource.restygwt.client.AbstractJsonEncoderDecoder<org.silverpeas.mobile.shared.dto.classifieds.ClassifiedsDTO> {
  
  public static final ClassifiedsDTO_Generated_JsonEncoderDecoder_ INSTANCE = new ClassifiedsDTO_Generated_JsonEncoderDecoder_();
  
  public com.google.gwt.json.client.JSONValue encode(org.silverpeas.mobile.shared.dto.classifieds.ClassifiedsDTO value) {
    if( value==null ) {
      return getNullType();
    }
      return encodeClassifiedsDTO662762726(value);
    }
    
    private com.google.gwt.json.client.JSONValue encodeClassifiedsDTO662762726( org.silverpeas.mobile.shared.dto.classifieds.ClassifiedsDTO value) {
      com.google.gwt.json.client.JSONObject rc = new com.google.gwt.json.client.JSONObject();
      com.google.gwt.json.client.JSONValue className=STRING.encode("ClassifiedsDTO");
      if( className!=null ) { 
        rc.put("@class", className);
      }
      org.silverpeas.mobile.shared.dto.classifieds.ClassifiedsDTO parseValue = (org.silverpeas.mobile.shared.dto.classifieds.ClassifiedsDTO)value;
      isNotNullValuePut(toJSON(parseValue.getTypes(), STRING, STRING, org.fusesource.restygwt.client.Json.Style.DEFAULT), rc, "types");
      isNotNullValuePut(toJSON(parseValue.getCategories(), STRING, STRING, org.fusesource.restygwt.client.Json.Style.DEFAULT), rc, "categories");
      isNotNullValuePut(toJSON(parseValue.getClassifieds(), org.silverpeas.mobile.shared.dto.classifieds.ClassifiedDTO_Generated_JsonEncoderDecoder_.INSTANCE), rc, "classifieds");
      isNotNullValuePut(BOOLEAN.encode(parseValue.getHasComments()), rc, "hasComments");
      isNotNullValuePut(STRING.encode(parseValue.getId()), rc, "id");
      return rc;
    }
    
    public org.silverpeas.mobile.shared.dto.classifieds.ClassifiedsDTO 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 decodeClassifiedsDTO662762726(object);
      }
      
      private org.silverpeas.mobile.shared.dto.classifieds.ClassifiedsDTO decodeClassifiedsDTO662762726(com.google.gwt.json.client.JSONObject object) {
        org.silverpeas.mobile.shared.dto.classifieds.ClassifiedsDTO rc = new org.silverpeas.mobile.shared.dto.classifieds.ClassifiedsDTO();
        rc.setTypes(getValueToSet(toMap(object.get("types"), STRING, STRING, org.fusesource.restygwt.client.Json.Style.DEFAULT), null));
        rc.setCategories(getValueToSet(toMap(object.get("categories"), STRING, STRING, org.fusesource.restygwt.client.Json.Style.DEFAULT), null));
        rc.setClassifieds(getValueToSet(toList(object.get("classifieds"), org.silverpeas.mobile.shared.dto.classifieds.ClassifiedDTO_Generated_JsonEncoderDecoder_.INSTANCE), null));
        rc.setHasComments(getValueToSet(BOOLEAN.decode(object.get("hasComments")), false));
        rc.setId(getValueToSet(STRING.decode(object.get("id")), null));
        return rc;
      }
      
    }
