Class ResponseDecomposer

java.lang.Object
org.ovirt.vdsm.jsonrpc.client.ResponseDecomposer

public class ResponseDecomposer extends Object
Decomposes of the response as objects which type is provided.
  • Field Details

    • log

      private static org.slf4j.Logger log
    • mapper

      private static com.fasterxml.jackson.databind.ObjectMapper mapper
    • response

      private JsonRpcResponse response
  • Constructor Details

    • ResponseDecomposer

      public ResponseDecomposer(JsonRpcResponse response)
      Creates decomposer for a response.
      Parameters:
      response - - Used for decomposition.
  • Method Details

    • isError

      public boolean isError()
      Returns:
      true when response contains JsonRpcError object otherwise false
    • decomposeResponse

      public <T> T decomposeResponse(Class<T> clazz)
      Decomposes response to provided type.
      Type Parameters:
      T - -Type of the object to which response will be decomposed.
      Parameters:
      clazz - - Class to which response will be decomposed.
      Returns:
      Decomposed response of provided type.
    • decomposeTypedArray

      public <T> T[] decomposeTypedArray(Object[] array, Class<T> clazz, String subtypeKey)
      Decomposes response to provided typed array.
      Type Parameters:
      T - -Type of the object to which response will be decomposed.
      Parameters:
      array - - An array of objects to be decomposed.
      clazz - - Class to which response will be decomposed.
      subtypeKey - - The key which is used to store objects in decomposed map.
      Returns:
      Decomposed response of provided type.
    • decomposeError

      public Map<String,Object> decomposeError()
      Decomposes response error as Map.
      Returns:
      Decomposed response error.