/*
 * Copyright 2015 Hewlett-Packard Development Company, L.P.
 * Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License.
 */

package com.hp.autonomy.hod.client.api.textindex.query.search;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Setter;
import lombok.experimental.Accessors;

import java.util.Collections;
import java.util.List;

/**
 * Top level response from the QueryTextIndex API and FindSimilar API.
 */
@Data
@AllArgsConstructor(access = AccessLevel.PRIVATE)
@JsonDeserialize(builder = Documents.Builder.class)
public class Documents {

    /**
     * @returns The list of documents returned by HP Haven OnDemand
     */
    private final List<Document> documents;

    /**
     * @returns The total number of results found by HP Haven OnDemand. If the total_results parameter was not specified,
     * this will be null.
     */
    private final Integer totalResults;

    @Setter
    @Accessors(chain = true)
    @JsonPOJOBuilder(withPrefix = "set")
    @JsonIgnoreProperties(ignoreUnknown = true)
    public static class Builder {

        @SuppressWarnings("FieldMayBeFinal")
        private List<Document> documents = Collections.emptyList();

        private Integer totalResults;

        @JsonProperty("totalhits")
        public Builder setTotalResults(final Integer totalResults) {
            this.totalResults = totalResults;
            return this;
        }

        public Documents build() {
            return new Documents(documents, totalResults);
        }

    }

}

@@ -574,68 +574,65 @@
 ta;%0A
+%0A
 import 
-lombok.Setter;%0Aimport lombok.experimental.Accessors;%0A
+java.io.Serializable;%0Aimport java.util.ArrayList;
 %0Aimp
@@ -896,163 +896,471 @@
 nts 
-%7B%0A%0A    /**%0A     * @returns The list of documents returned by HP Haven OnDemand%0A     */%0A    private final List%3CDocument%3E documents;%0A%0A    /**%0A     * @returns
+implements Serializable %7B%0A%0A    private static final long serialVersionUID = 7657511117355673864L;%0A%0A    /**%0A     * @return The list of documents returned by HP Haven OnDemand%0A     * @serial The list of documents returned by HP Haven OnDemand%0A     */%0A    private final List%3CDocument%3E documents;%0A%0A    /**%0A     * @return The total number of results found by HP Haven OnDemand. If the total_results parameter was not specified,%0A     * this will be null.%0A     * @serial
  The
@@ -1541,49 +1541,8 @@
 s;%0A%0A
-    @Setter%0A    @Accessors(chain = true)%0A
     
@@ -1810,24 +1810,243 @@
 alResults;%0A%0A
+        public Builder setDocuments(final List%3CDocument%3E documents) %7B%0A            if (documents != null) %7B%0A                this.documents = new ArrayList%3C%3E(documents);%0A            %7D%0A%0A            return this;%0A        %7D%0A%0A
         @Jso

Implement Serializable on Documents. [rev: matthew.gordon]