Class BaseCollectionRequest<T,​T2 extends ICollectionResponse<T>,​T3 extends BaseCollectionPage<T,​? extends BaseRequestBuilder<T>>>

java.lang.Object
com.microsoft.graph.http.BaseCollectionRequest<T,​T2,​T3>
Type Parameters:
T - the type of the object in the collection
T2 - the response collection type
T3 - the collection page type
All Implemented Interfaces:
IHttpRequest
Direct Known Subclasses:
BaseActionCollectionRequest, BaseEntityCollectionRequest, BaseFunctionCollectionRequest, BaseVoidActionCollectionRequest

public abstract class BaseCollectionRequest<T,​T2 extends ICollectionResponse<T>,​T3 extends BaseCollectionPage<T,​? extends BaseRequestBuilder<T>>> extends Object implements IHttpRequest
A request against a collection
  • Field Details

    • responseCollectionClass

      protected final Class<T2 extends ICollectionResponse<T>> responseCollectionClass
      The class for the response collection
  • Constructor Details

    • BaseCollectionRequest

      public BaseCollectionRequest(@Nonnull String requestUrl, @Nonnull IBaseClient<?> client, @Nullable List<? extends Option> options, @Nonnull Class<T2> responseCollectionClass, @Nonnull Class<T3> collectionPageClass, @Nonnull Class<? extends BaseCollectionRequestBuilder<T,​? extends BaseRequestBuilder<T>,​T2,​T3,​? extends BaseCollectionRequest<T,​T2,​T3>>> collectionRequestBuilderClass)
      Create the collection request
      Parameters:
      requestUrl - the URL to make the request against
      client - the client which can issue the request
      options - the options for this request
      responseCollectionClass - the class for the response collection
      collectionPageClass - the class for the collection page
      collectionRequestBuilderClass - the class for the collection request builder
  • Method Details

    • send

      @Nullable protected T2 send() throws ClientException
      Send this request
      Returns:
      the response object
      Throws:
      ClientException - an exception occurs if there was an error while the request was sent
    • sendAsync

      @Nullable protected CompletableFuture<T2> sendAsync() throws ClientException
      Send this request
      Returns:
      the response object
      Throws:
      ClientException - an exception occurs if there was an error while the request was sent
    • buildFromResponse

      @Nullable public T3 buildFromResponse(@Nonnull T2 response)
      Deserializes the collection from the response object
      Parameters:
      response - the collection response
      Returns:
      the collection page
    • getRequestUrl

      @Nonnull public URL getRequestUrl()
      Gets the request URL
      Specified by:
      getRequestUrl in interface IHttpRequest
      Returns:
      the request URL
    • getHttpMethod

      @Nullable public HttpMethod getHttpMethod()
      Gets the HTTP method
      Specified by:
      getHttpMethod in interface IHttpRequest
      Returns:
      the HTTP method
    • getHeaders

      @Nullable public List<HeaderOption> getHeaders()
      Gets the headers
      Specified by:
      getHeaders in interface IHttpRequest
      Returns:
      the headers
    • addHeader

      public void addHeader(@Nonnull String header, @Nullable String value)
      Adds a header to this request
      Specified by:
      addHeader in interface IHttpRequest
      Parameters:
      header - the name of the header
      value - the value of the header
    • setUseCaches

      public void setUseCaches(boolean useCaches)
      Sets useCaches parameter to cache the response
      Specified by:
      setUseCaches in interface IHttpRequest
      Parameters:
      useCaches - the value of useCaches
    • getUseCaches

      public boolean getUseCaches()
      Gets useCaches parameter
      Specified by:
      getUseCaches in interface IHttpRequest
      Returns:
      the value of useCaches
    • getOptions

      @Nullable public List<Option> getOptions()
      Gets the full list of options for this request
      Specified by:
      getOptions in interface IHttpRequest
      Returns:
      the full list of options for this request
    • addQueryOption

      public void addQueryOption(@Nonnull QueryOption option)
      Adds a query option
      Parameters:
      option - the query option to add
    • addExpandOption

      protected void addExpandOption(@Nonnull String value)
      Sets the expand clause for the request
      Parameters:
      value - the expand clause
    • addFilterOption

      protected void addFilterOption(@Nonnull String value)
      Sets the filter clause for the request
      Parameters:
      value - the filter clause
    • addOrderByOption

      protected void addOrderByOption(@Nonnull String value)
      Sets the order by clause for the request
      Parameters:
      value - the order by clause
    • addSelectOption

      protected void addSelectOption(@Nonnull String value)
      Sets the select clause for the request
      Parameters:
      value - the select clause
    • addTopOption

      protected void addTopOption(int value)
      Sets the top value for the request
      Parameters:
      value - the max number of items to return
    • addSkipOption

      protected void addSkipOption(int value)
      Sets the skip value for the request
      Parameters:
      value - of the number of items to skip
    • addSkipTokenOption

      protected void addSkipTokenOption(@Nonnull String skipToken)
      Add Skip token for pagination
      Parameters:
      skipToken - - Token for pagination
    • addCountOption

      protected void addCountOption(boolean value)
      Adds the count query string value for the request
      Parameters:
      value - - Wheter to return the count or not
    • addFunctionOption

      public void addFunctionOption(@Nonnull FunctionOption option)
      Adds a query option
      Parameters:
      option - the query option to add
    • getBaseRequest

      @Nonnull public BaseRequest<T2> getBaseRequest()
      Gets the base request for this collection request
      Returns:
      the base request for this collection request
    • getCollectionPageClass

      @Nonnull public Class<T3> getCollectionPageClass()
      Gets the class for the collection page
      Returns:
      the class for the collection page
    • setMaxRedirects

      public void setMaxRedirects(int maxRedirects)
      Sets the max redirects
      Specified by:
      setMaxRedirects in interface IHttpRequest
      Parameters:
      maxRedirects - Max redirects that a request can take
    • getMaxRedirects

      public int getMaxRedirects()
      Gets the max redirects
      Specified by:
      getMaxRedirects in interface IHttpRequest
      Returns:
      Max redirects that a request can take
    • setShouldRedirect

      public void setShouldRedirect(@Nonnull IShouldRedirect shouldRedirect)
      Sets the should redirect callback
      Specified by:
      setShouldRedirect in interface IHttpRequest
      Parameters:
      shouldRedirect - Callback called before doing a redirect
    • getShouldRedirect

      @Nonnull public IShouldRedirect getShouldRedirect()
      Gets the should redirect callback
      Specified by:
      getShouldRedirect in interface IHttpRequest
      Returns:
      Callback which is called before redirect
    • setShouldRetry

      public void setShouldRetry(@Nonnull IShouldRetry shouldretry)
      Sets the should retry callback
      Specified by:
      setShouldRetry in interface IHttpRequest
      Parameters:
      shouldretry - The callback called before retry
    • getShouldRetry

      @Nonnull public IShouldRetry getShouldRetry()
      Gets the should retry callback
      Specified by:
      getShouldRetry in interface IHttpRequest
      Returns:
      Callback called before retry
    • setMaxRetries

      public void setMaxRetries(int maxRetries)
      Sets the max retries
      Specified by:
      setMaxRetries in interface IHttpRequest
      Parameters:
      maxRetries - Max retries for a request
    • getMaxRetries

      public int getMaxRetries()
      Gets max retries
      Specified by:
      getMaxRetries in interface IHttpRequest
      Returns:
      Max retries for a request
    • setDelay

      public void setDelay(long delay)
      Sets the delay in seconds between retires
      Specified by:
      setDelay in interface IHttpRequest
      Parameters:
      delay - Delay in seconds between retries
    • getDelay

      public long getDelay()
      Gets delay between retries
      Specified by:
      getDelay in interface IHttpRequest
      Returns:
      Delay between retries in seconds
    • withHttpMethod

      @Nullable public IHttpRequest withHttpMethod(@Nonnull HttpMethod httpMethod)
      Sets the HTTP method and returns the current request
      Specified by:
      withHttpMethod in interface IHttpRequest
      Parameters:
      httpMethod - the HTTP method
      Returns:
      the current request
    • getHttpRequest

      @Nullable public <requestBodyType,​ responseType,​ nativeRequestType> nativeRequestType getHttpRequest(@Nullable requestBodyType serializedObject) throws ClientException
      Returns the Request object to be executed
      Specified by:
      getHttpRequest in interface IHttpRequest
      Type Parameters:
      requestBodyType - the type of the serialized object
      responseType - the type of the response
      nativeRequestType - type of a request for the native http client
      Parameters:
      serializedObject - the object to serialize at the body of the request
      Returns:
      the Request object to be executed
      Throws:
      ClientException