/*
 * The MIT License (MIT)
 *
 * Copyright (c) 2017 Newhouse (nhitbh at gmail dot com)
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

package com.fooock.shodan.model.exploit;

import com.google.gson.annotations.SerializedName;

import java.util.Arrays;
import java.util.List;

/**
 * Class that contains a list of exploits, facets and the total number of exploits for a given
 * query. Note that the list of exploits can be empty if this is the result of calling the exploit
 * api with {@link com.fooock.shodan.ShodanExploitApi#count(String)} method. Also the facets info
 * can be empty if no facets query is provided
 */
public class ExploitReport {

    @SerializedName("matches")
    private final List<Exploit> exploits;

    @SerializedName("facets")
    private final Facet facets;

    private final int total;

    ExploitReport(List<Exploit> exploits, Facet facets, int total) {
        this.exploits = exploits;
        this.facets = facets == null ? new Facet() : facets;
        this.total = total;
    }

    public List<Exploit> getExploits() {
        return exploits;
    }

    public Facet getFacets() {
        return facets;
    }

    public int getTotal() {
        return total;
    }

    @Override
    public String toString() {
        return "ExploitReport{" +
                "exploits=" + Arrays.deepToString(exploits.toArray()) +
                ", facets=" + facets +
                ", total=" + total +
                '}';
    }
}