org.esbtools.eventhandler.lightblue.client

Interface LightblueResponse



  • public interface LightblueResponse
    Represents a lightblue response which may or may not have been successful.

    To wrap a response from the lightblue client library, see fromClientResponse(com.redhat.lightblue.client.response.LightblueResponse)

    Typical use cases vary on how you would handle a failed response

    • "I would throw an exception": In this case just use getSuccess() and let the exception propagate if it failed.
    • "I would examine the errors before doing something else": In this case call isSuccess() first, and if false use the response from getFailure()
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method and Description
      static LightblueResponse fromClientResponse(com.redhat.lightblue.client.response.LightblueResponse response)
      Wraps a response from the lightblue client library which may or may not be successful in a type which allows easily querying whether or not the response was successful and getting at the right type of response.
      com.redhat.lightblue.client.response.LightblueErrorResponse getFailure() 
      com.redhat.lightblue.client.response.LightblueDataResponse getSuccess()
      Returns the response if it was successful as a LightblueDataResponse matching the successful lightblue response schema.
      boolean isSuccess()
      This response can represent both a successful and failed one.
    • Method Detail

      • getSuccess

        com.redhat.lightblue.client.response.LightblueDataResponse getSuccess()
                                                                       throws LightblueResponseException
        Returns the response if it was successful as a LightblueDataResponse matching the successful lightblue response schema. If the response was not successful, then an unchecked LightblueResponseException is thrown with the lightblue errors in the response.

        You should query if the response was successful or not first with isSuccess(), unless all you would do is throw an exception if it failed. In that case, you could just call getSuccess() unconditionally and let the exception propagate.

        Throws:
        LightblueResponseException - if this response is not a successful one. Check if the response is successful first with isSuccess().
      • isSuccess

        boolean isSuccess()
        This response can represent both a successful and failed one. Use this to query which it is.
      • getFailure

        com.redhat.lightblue.client.response.LightblueErrorResponse getFailure()
                                                                        throws NoSuchElementException
        Returns:
        A failed lightblue response with one or more errors.
        Throws:
        NoSuchElementException - if this response is not a failed one. Check if the response is successful first with isSuccess().
      • fromClientResponse

        static LightblueResponse fromClientResponse(com.redhat.lightblue.client.response.LightblueResponse response)
        Wraps a response from the lightblue client library which may or may not be successful in a type which allows easily querying whether or not the response was successful and getting at the right type of response.

Copyright © 2017. All rights reserved.