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

com.opentext.ia.sdk.dto.SearchResults Maven / Gradle / Ivy

There is a newer version: 12.8.4
Show newest version
/*
 * Copyright (c) 2016-2017 by OpenText Corporation. All Rights Reserved.
 */
package com.opentext.ia.sdk.dto;

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

import com.fasterxml.jackson.annotation.JsonProperty;
import com.opentext.ia.sdk.support.http.rest.LinkContainer;


public class SearchResults extends LinkContainer {

  private static final String KEY = "results";
  private final List results = new ArrayList<>();

  @JsonProperty("_embedded")
  protected void setEmbedded(Map> embedded) {
    results.clear();
    List embeddedItems = embedded.get(KEY);
    if (embeddedItems == null) {
      throw new IllegalArgumentException(String.format("Expected results under key '%s', but got keys %s", KEY,
          embedded.keySet()));
    }
    results.addAll(embeddedItems);
  }

  public List getResults() {
    return results;
  }

  public void addResult(SearchResult searchResult) {
    results.add(searchResult);
  }

  public List getRows() {
    List rows = new ArrayList<>();
    for (SearchResult searchResult: results) {
      rows.addAll(searchResult.getRows());
    }
    return rows;
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy