Class RequestResponseOK<T>

  • Type Parameters:
    T - Type of results

    public final class RequestResponseOK<T>
    extends RequestResponse<T>
    Access RequestResponseOK class contains list of results
    default results : is an empty list (immutable)
    • Field Detail

      • TAG_RESULTS

        public static final java.lang.String TAG_RESULTS
        result in response
        See Also:
        Constant Field Values
      • TAG_FACET_RESULTS

        public static final java.lang.String TAG_FACET_RESULTS
        facet results in response
        See Also:
        Constant Field Values
      • TAG_CONTEXT

        public static final java.lang.String TAG_CONTEXT
        context in response
        See Also:
        Constant Field Values
    • Constructor Detail

      • RequestResponseOK

        public RequestResponseOK()
        Empty RequestResponseOK constructor
      • RequestResponseOK

        public RequestResponseOK​(com.fasterxml.jackson.databind.JsonNode query)
        Initialize from a query
        Parameters:
        query -
      • RequestResponseOK

        public RequestResponseOK​(com.fasterxml.jackson.databind.JsonNode query,
                                 java.util.List<T> results,
                                 int total)
        Initialize from a query and results
        Parameters:
        query -
      • RequestResponseOK

        public RequestResponseOK​(com.fasterxml.jackson.databind.JsonNode query,
                                 java.util.List<T> results,
                                 int total,
                                 java.lang.String scrollId)
        Initialize from a query and results
        Parameters:
        query -
    • Method Detail

      • addResult

        public RequestResponseOK<T> addResult​(T result)
        Add one result
        Parameters:
        result - to add to request response
        Returns:
        this
      • addAllResults

        public RequestResponseOK<T> addAllResults​(java.util.List<T> resultList)
        Add list of results
        Parameters:
        resultList - the list of results
        Returns:
        RequestResponseOK with mutable results list of String
      • addFacetResult

        public RequestResponseOK<T> addFacetResult​(FacetResult facetResult)
        Add one facetResult
        Parameters:
        facetResult - to add to request response
        Returns:
        this
      • addAllFacetResults

        public RequestResponseOK<T> addAllFacetResults​(java.util.List<FacetResult> facetResultList)
        Add list of facetResult
        Parameters:
        facetResultList - the list of facetResults
        Returns:
        RequestResponseOK with mutable results list of String
      • getHits

        public DatabaseCursor getHits()
        Returns:
        the hits of RequestResponseOK object
      • setHits

        public RequestResponseOK<T> setHits​(DatabaseCursor hits)
        Parameters:
        hits - as DatabaseCursor object
        Returns:
        RequestReponseOK with the hits are setted
      • setHits

        public RequestResponseOK<T> setHits​(long total,
                                            int offset,
                                            int limit)
        Parameters:
        total - of units inserted/modified as integer
        offset - of unit in database as integer
        limit - of unit per response as integer
        Returns:
        the RequestReponseOK with the hits are setted
      • setHits

        public RequestResponseOK<T> setHits​(long total,
                                            int offset,
                                            int limit,
                                            int size,
                                            java.lang.String scrollId)
        Parameters:
        total - of units inserted/modified as integer
        offset - of unit in database as integer
        limit - of unit per response as integer
        size - of unit per response
        scrollId - of response
        Returns:
        the RequestReponseOK with the hits are setted
      • setHits

        public RequestResponseOK<T> setHits​(long total,
                                            int offset,
                                            int limit,
                                            int size)
        Parameters:
        total - of units inserted/modified as integer
        offset - of unit in database as integer
        limit - of unit per response as integer
        size - of unit per response
        Returns:
        the RequestReponseOK with the hits are setted
      • setTotal

        public RequestResponseOK<T> setTotal​(long total)
        Should be used only with hints of elasticsearch
        Parameters:
        total -
        Returns:
      • setScrollId

        public RequestResponseOK<T> setScrollId​(java.lang.String scrollId)
        When activate scroll
        Parameters:
        scrollId -
        Returns:
      • getFacetResults

        public java.util.List<FacetResult> getFacetResults()
        Returns:
        the facetResults
      • getResults

        public java.util.List<T> getResults()
        Returns:
        the result of RequestResponse as a list of
      • getQuery

        public com.fasterxml.jackson.databind.JsonNode getQuery()
        Returns:
        the query as JsonNode of Response
      • getFirstResult

        public T getFirstResult()
        Returns:
        the first result of RequestResponse as a
      • setQuery

        public RequestResponseOK<T> setQuery​(com.fasterxml.jackson.databind.JsonNode query)
        Parameters:
        query - the set to request response
        Returns:
        this
      • isEmpty

        public boolean isEmpty()
        Returns:
        True if the result is empty
      • toResponse

        public javax.ws.rs.core.Response toResponse()
        transform a RequestResponse to a standard response
        Specified by:
        toResponse in class RequestResponse<T>
        Returns:
        Response