/*
 * Copyright (c) 2014-2015 VMware, Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License.  You may obtain a copy of
 * the License at http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed
 * under the License is distributed on an "AS IS" BASIS, without warranties or
 * conditions of any kind, EITHER EXPRESS OR IMPLIED.  See the License for the
 * specific language governing permissions and limitations under the License.
 */

package com.vmware.xenon.common;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class ServiceDocumentQueryResult extends ServiceDocument {
    public static final String FIELD_NAME_DOCUMENT_LINKS = "documentLinks";
    /**
     * Collection of self links associated with each document found. The self link acts as the
     * primary key for a document.
     */
    public List<String> documentLinks = new ArrayList<>();

    /**
     * If the query included an expand directory, this map contains the JSON serialized service
     * state document associated with each link
     */
    public Map<String, Object> documents;

    /**
     * Set to the number of documents that satisfy the query.
     */
    public Long documentCount;

    /**
     * Valid only if QuerySpecification.resultLimit is specified.
     * In which case, a GET request to this link will retrieve the previous page of query results.
     * This link will expire roughly at the same time as the original QueryTask.
     */
    public String prevPageLink;

    /**
     * Valid only if QuerySpecification.resultLimit is specified.
     * In which case, a GET request to this link will retrieve the next page of query results.
     * This link will expire roughly at the same time as the original QueryTask.
     */
    public String nextPageLink;

    /**
     * Duration of the query execution.
     */
    public Long queryTimeMicros;
}

@@ -783,16 +783,17 @@
 ument %7B%0A
+%0A
     publ
@@ -860,16 +860,391 @@
 Links%22;%0A
+    public static final String FIELD_NAME_DOCUMENTS = %22documents%22;%0A    public static final String FIELD_NAME_DOCUMENT_COUNT = %22documentCount%22;%0A    public static final String FIELD_NAME_PREV_PAGE_LINK = %22prevPageLink%22;%0A    public static final String FIELD_NAME_NEXT_PAGE_LINK = %22nextPageLink%22;%0A    public static final String FIELD_NAME_QUERY_TIME_MICROS = %22queryTimeMicros%22;%0A%0A
     /**%0A
@@ -2428,11 +2428,561 @@
 eMicros;
+%0A%0A    /**%0A     * Returns whether or not the %7B@code name%7D is a built-in field.%0A     *%0A     * @param name Field name%0A     * @return true/false%0A     */%0A    public static boolean isBuiltInField(String name) %7B%0A        switch (name) %7B%0A        case FIELD_NAME_DOCUMENT_LINKS:%0A        case FIELD_NAME_DOCUMENTS:%0A        case FIELD_NAME_DOCUMENT_COUNT:%0A        case FIELD_NAME_PREV_PAGE_LINK:%0A        case FIELD_NAME_NEXT_PAGE_LINK:%0A        case FIELD_NAME_QUERY_TIME_MICROS:%0A            return true;%0A        default:%0A            return false;%0A        %7D%0A    %7D
 %0A%7D%0A

add is built in field method