Interface APIResponses

All Superinterfaces:
Constructible, Extensible<APIResponses>, Map<String,APIResponse>

public interface APIResponses extends Constructible, Extensible<APIResponses>, Map<String,APIResponse>
This interface represents the container for the expected responses of an operation. The container maps a HTTP response code to the expected response.
See Also:
  • Field Details

  • Method Details

    • addApiResponse

      @Deprecated default APIResponses addApiResponse(String name, APIResponse apiResponse)
      Deprecated.
      Adds an APIResponse in the format of the name as a key and the item as the value to APIResponses map
      Parameters:
      name - the name of APIResponse (http status code eventually with wildcard or "default")
      apiResponse - the APIResponse object to be added to APIResponses map. null values will be rejected (implementation will throw an exception) or ignored.
      Returns:
      APIResponses map with the added ApiResponse instance
    • addAPIResponse

      APIResponses addAPIResponse(String name, APIResponse apiResponse)
      Adds an APIResponse in the format of the name as a key and the item as the value to APIResponses map
      Parameters:
      name - the name of APIResponse (http status code eventually with wildcard or "default")
      apiResponse - the APIResponse object to be added to APIResponses map. null values will be rejected (implementation will throw an exception) or ignored.
      Returns:
      APIResponses map with the added ApiResponse instance
    • removeAPIResponse

      void removeAPIResponse(String name)
      Removes the given APIResponse to this APIResponses.
      Parameters:
      name - the name of APIResponse that will be removed (http status code eventually with wildcard or "default")
    • getAPIResponses

      Map<String,APIResponse> getAPIResponses()
      Returns a copy map (potentially immutable) of the APIResponses.
      Returns:
      all responses
    • setAPIResponses

      void setAPIResponses(Map<String,APIResponse> items)
      Set the APIResponses map to this APIResponses
      Parameters:
      items - a map containing all responses. Keys are http statuses code eventually with wildcard or "default".
    • hasAPIResponse

      default boolean hasAPIResponse(String name)
      Check whether a APIResponse is present in the map. This is a convenience method for getAPIResponses().containsKey(name)
      Parameters:
      name - the name of APIResponse (http status code eventually with wildcard or "default")
      Returns:
      a boolean to indicate if the APIResponse is present or not.
    • getAPIResponse

      default APIResponse getAPIResponse(String name)
      Returns a APIResponse for a given name. This is a convenience method for getAPIResponses().get(name)
      Parameters:
      name - the name of APIResponse (http status code eventually with wildcard or "default")
      Returns:
      the corresponding APIResponse or null.
    • get

      Deprecated.
      since 1.1
      In the next version, APIResponses will no longer extends Map, this method will no longer be present. Use getAPIResponse(String) instead.
      Specified by:
      get in interface Map<String,APIResponse>
    • containsKey

      @Deprecated boolean containsKey(Object key)
      Deprecated.
      since 1.1
      In the next version, APIResponses will no longer extends Map, this method will no longer be present. Use hasAPIResponse(String) instead.
      Specified by:
      containsKey in interface Map<String,APIResponse>
    • put

      Deprecated.
      since 1.1
      In the next version, APIResponses will no longer extends Map, this method will no longer be present. Use addAPIResponse(String, APIResponse) instead.
      Specified by:
      put in interface Map<String,APIResponse>
    • putAll

      @Deprecated void putAll(Map<? extends String,? extends APIResponse> m)
      Deprecated.
      since 1.1
      In the next version, APIResponses will no longer extends Map, this method will no longer be present. Use setAPIResponses(Map) instead.
      Specified by:
      putAll in interface Map<String,APIResponse>
    • remove

      Deprecated.
      since 1.1
      In the next version, APIResponses will no longer extends Map, this method will no longer be present. Use removeAPIResponse(String) instead.
      Specified by:
      remove in interface Map<String,APIResponse>
    • getDefault

      @Deprecated default APIResponse getDefault()
      Deprecated.
      since 1.1, use @link getDefaultValue() instead
      Returns the default documentation of responses other than the ones declared for specific HTTP response codes in this instance of ApiResponses.

      Convenience method that is the same as calling get(Object) on the map with "default" as value for the key.

      Returns:
      the default documentation of responses
    • getDefaultValue

      APIResponse getDefaultValue()
      Returns the default documentation of responses other than the ones declared for specific HTTP response codes in this instance of ApiResponses.

      Convenience method that is the same as calling get(Object) on the map with "default" as value for the key.

      Returns:
      the default documentation of responses
    • setDefaultValue

      void setDefaultValue(APIResponse defaultValue)
      Sets the default documentation of responses for this instance of ApiResponses. This will cover all the undeclared responses.

      Convenience method that is the same as calling addAPIResponse(String, APIResponse) with "default" as value for the key.

      Parameters:
      defaultValue - the default documentation of responses
    • defaultValue

      default APIResponses defaultValue(APIResponse defaultValue)
      Sets the default documentation of responses for this instance of ApiResponses and return this instance of ApiResponses. This will cover all the undeclared responses.

      Convenience method that is the same as calling addAPIResponse(String, APIResponse) with "default" as value for the key.

      Parameters:
      defaultValue - the default documentation of responses
      Returns:
      this ApiResponses instance