// Path: src/main/java/org/springframework/data/cloudant/core/model/BaseDocument.java
// @JsonInclude(JsonInclude.Include.ALWAYS)
// public class BaseDocument {
// 
//     @SerializedName("_id")
//     @Id
//     private String id;
// 
//     @SerializedName("_rev")
//     private String revision;
// 
//     //json ignore
//     @JsonIgnore
//     private Map<String, Object> unmappedFields;
// 
//     @JsonProperty("_id")
//     public String getId() {
//         return id;
//     }
// 
//     @JsonProperty("_id")
//     public void setId(String id) {
//         this.id = id;
//     }
// 
//     @JsonProperty("_rev")
//     public String getRevision() {
//         return revision;
//     }
// 
//     @JsonProperty("_rev")
//     public void setRevision(String revision) {
//         this.revision = revision;
//     }
// 
//     public void setUnmappedFields(Map<String, Object> unmappedFields) {
//         this.unmappedFields = unmappedFields;
//     }
// 
//     public Map<String, Object> getUnmappedFields() {
//         return unmappedFields;
//     }
// 
//     public void addUnmappedField(String key, Object value) {
//         if (unmappedFields == null) {
//             unmappedFields = new HashMap<String, Object>();
//         }
//         unmappedFields.put(key,value);
//     }
// }


import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;
import com.cloudant.client.api.CloudantClient;
import com.cloudant.client.api.model.ConnectOptions;
import com.cloudant.client.api.Database;
import com.google.gson.GsonBuilder;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.dao.DataAccessException;
import org.springframework.dao.support.PersistenceExceptionTranslator;
import org.springframework.data.cloudant.core.model.BaseDocument;

    public void setGsonBuilder(final GsonBuilder gsonBuilder) { this.gsonBuilder = gsonBuilder; }

    /**
     * Use SLF4J as the default logger if not instructed otherwise.
     */
    public static final String DEFAULT_LOGGER_PROPERTY = "net.spy.memcached.compat.log.SLF4JLogger";
    //factory builder?

    @Override
    public CloudantClient getObject() throws Exception {
        return cloudantClient;
    }

    @Override
    public Class<?> getObjectType() {
        return CloudantClient.class;
    }

    @Override
    public boolean isSingleton() {
        return true;
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        ConnectOptions connectionOptions = new ConnectOptions()
                .setConnectionTimeout(connectionTimeout)
                .setMaxConnections(maxConnections);
        cloudantClient = new CloudantClient(account,username,password,connectionOptions);
// Path: src/main/java/org/springframework/data/cloudant/core/model/BaseDocument.java
// @JsonInclude(JsonInclude.Include.ALWAYS)
// public class BaseDocument {
// 
//     @SerializedName("_id")
//     @Id
//     private String id;
// 
//     @SerializedName("_rev")
//     private String revision;
// 
//     //json ignore
//     @JsonIgnore
//     private Map<String, Object> unmappedFields;
// 
//     @JsonProperty("_id")
//     public String getId() {
//         return id;
//     }
// 
//     @JsonProperty("_id")
//     public void setId(String id) {
//         this.id = id;
//     }
// 
//     @JsonProperty("_rev")
//     public String getRevision() {
//         return revision;
//     }
// 
//     @JsonProperty("_rev")
//     public void setRevision(String revision) {
//         this.revision = revision;
//     }
// 
//     public void setUnmappedFields(Map<String, Object> unmappedFields) {
//         this.unmappedFields = unmappedFields;
//     }
// 
//     public Map<String, Object> getUnmappedFields() {
//         return unmappedFields;
//     }
// 
//     public void addUnmappedField(String key, Object value) {
//         if (unmappedFields == null) {
//             unmappedFields = new HashMap<String, Object>();
//         }
//         unmappedFields.put(key,value);
//     }
// }


// Path: src/main/java/org/springframework/data/cloudant/core/CloudantFactoryBean.java
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;
import com.cloudant.client.api.CloudantClient;
import com.cloudant.client.api.model.ConnectOptions;
import com.cloudant.client.api.Database;
import com.google.gson.GsonBuilder;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.dao.DataAccessException;
import org.springframework.dao.support.PersistenceExceptionTranslator;
import org.springframework.data.cloudant.core.model.BaseDocument;


    public void setGsonBuilder(final GsonBuilder gsonBuilder) { this.gsonBuilder = gsonBuilder; }

    /**
     * Use SLF4J as the default logger if not instructed otherwise.
     */
    public static final String DEFAULT_LOGGER_PROPERTY = "net.spy.memcached.compat.log.SLF4JLogger";
    //factory builder?

    @Override
    public CloudantClient getObject() throws Exception {
        return cloudantClient;
    }

    @Override
    public Class<?> getObjectType() {
        return CloudantClient.class;
    }

    @Override
    public boolean isSingleton() {
        return true;
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        ConnectOptions connectionOptions = new ConnectOptions()
                .setConnectionTimeout(connectionTimeout)
                .setMaxConnections(maxConnections);
        cloudantClient = new CloudantClient(account,username,password,connectionOptions);
        gsonBuilder = new GsonBuilder().registerTypeHierarchyAdapter(BaseDocument.class,new UnmappedDataAdapter());