Class DataAPIResponse

java.lang.Object
com.datastax.astra.internal.api.DataAPIResponse
All Implemented Interfaces:
Serializable

public class DataAPIResponse extends Object implements Serializable
Represents the generic response structure for API calls. This class encapsulates different segments of the response, such as status information, error details, and data returned by 'find' operations. It provides flexibility to handle various types of responses within a unified framework.
See Also:
  • Constructor Details

    • DataAPIResponse

      public DataAPIResponse()
      Default constructor for DataAPIResponse. Initializes a new instance of the class without setting any properties.
  • Method Details

    • getStatusKeyAsStringStream

      public Stream<String> getStatusKeyAsStringStream(@NonNull @NonNull String key)
      Retrieves a stream of String values from the 'status' map based on the provided key. This method is useful for processing multiple values associated with a single key in the status information.
      Parameters:
      key - The key for which to retrieve the values.
      Returns:
      A Stream of String values associated with the specified key; an empty stream if the key does not exist.
    • getStatusKeyAsList

      public <T> List<T> getStatusKeyAsList(@NonNull @NonNull String key, Class<T> targetClass)
      Retrieves a list of objects from the 'status' map based on the provided key, casting them to the specified class. This method is suitable for cases where the status information contains lists of objects under a single key.
      Type Parameters:
      T - The type of the objects in the list to be returned.
      Parameters:
      key - The key for which to retrieve the list.
      targetClass - The class to which the objects in the list should be cast.
      Returns:
      The list of objects associated with the specified key, cast to the specified class; null if the key does not exist.
    • getStatusKeyAsMap

      public <T> Map<String,T> getStatusKeyAsMap(@NonNull @NonNull String key, Class<T> targetClass)
      Retrieves a list of objects from the 'status' map based on the provided key, casting them to the specified class. This method is suitable for cases where the status information contains lists of objects under a single key.
      Type Parameters:
      T - The type of the objects in the list to be returned.
      Parameters:
      key - The key for which to retrieve the list.
      targetClass - The class to which the objects in the list should be cast.
      Returns:
      The list of objects associated with the specified key, cast to the specified class; null if the key does not exist.
    • getStatus

      public <T> T getStatus(Class<T> targetClass)
      Retrieves a single object from the 'status' map based on the provided key, casting it to the specified class. This method is suitable for cases where the status information contains a single object under a specific key.
      Type Parameters:
      T - The type of the object to be returned.
      Parameters:
      targetClass - The class to which the object should be cast.
      Returns:
      The object associated with the specified key, cast to the specified class; null if the key does not exist.