All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.scaleset.search.Results Maven / Gradle / Ivy

There is a newer version: 0.24.0
Show newest version
package com.scaleset.search;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.vividsolutions.jts.geom.Envelope;

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

@JsonPropertyOrder({"headers", "query", "totalItems", "aggs", "bbox", "items"})
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class Results {

    private Map aggs = new HashMap<>();
    private List items = new ArrayList<>();
    private Query query;
    private Integer totalItems = 0;
    private Envelope bbox;
    private Map headers = new HashMap();

    /* For Jackson */
    protected Results() {
    }

    public Results(Query query, Map aggs, List items, Integer totalItems) {
        this(query, aggs, items, totalItems, null, null);
    }

    public Results(Query query, Map aggs, List items, Integer totalItems, Envelope bbox, Map headers) {
        this.query = query;
        if (aggs != null) {
            this.aggs.putAll(aggs);
        }
        this.items.addAll(items);
        this.totalItems = totalItems;
        this.bbox = bbox;
        if (headers != null) {
            this.headers.putAll(headers);
        }
    }

    public Results(Query query, List items) {
        this.query = query;
        this.items.addAll(items);
    }

    public Envelope getBbox() {
        return bbox;
    }

    public AggregationResults getAgg(String name) {
        return aggs.get(name);
    }

    public Map getAggs() {
        return aggs;
    }

    public Map getHeaders() {
        return headers;
    }

    public List getItems() {
        return items;
    }

    public Query getQuery() {
        return query;
    }

    public Integer getTotalItems() {
        return totalItems;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy