Interface RepresentationModel

All Known Subinterfaces:
ErrorRepresentationModel

public interface RepresentationModel
This class provides a view of the response model information present in a Response, to be used by RepresentationFunction.
Since:
5.4.0
  • Method Details

    • getString

      String getString(String key)
      Return the String associated to key.
      Parameters:
      key - the key to lookup
      Returns:
      the String associated to key
      Throws:
      NoSuchElementException - the model does not contain any entry for key
      ClassCastException - the value associated to key is not convertible to a String
    • getInt

      int getInt(String key)
      Return the int associated to key.
      Parameters:
      key - the key to lookup
      Returns:
      the int associated to key
      Throws:
      NoSuchElementException - the model does not contain any entry for key
      ClassCastException - the value associated to key is not convertible to a int
    • getLong

      long getLong(String key)
      Return the long associated to key.
      Parameters:
      key - the key to lookup
      Returns:
      the long associated to key
      Throws:
      NoSuchElementException - the model does not contain any entry for key
      ClassCastException - the value associated to key is not convertible to a long
    • getBoolean

      boolean getBoolean(String key)
      Return the boolean associated to key.
      Parameters:
      key - the key to lookup
      Returns:
      the boolean associated to key
      Throws:
      NoSuchElementException - the model does not contain any entry for key
      ClassCastException - the value associated to key is not convertible to a boolean
    • getBoolean

      boolean getBoolean(String key, boolean defaultValue)
      Return the boolean associated to key.
      Parameters:
      key - the key to lookup
      defaultValue - the default value to use if the model doesn't contain any entry for key
      Returns:
      the boolean associated to key or the default value.
      Throws:
      ClassCastException - the value associated to key is not convertible to a boolean
    • getAs

      <T> T getAs(String key, Class<T> type)
      Return the RepresentationModel associated to key.
      Type Parameters:
      T - the type of the value being retrived from the model
      Parameters:
      key - the key to lookup
      Returns:
      the RepresentationModel associated to key
      Throws:
      NoSuchElementException - the model does not contain any entry for key
      ClassCastException - the value associated to key is not convertible to a RepresentationModel
    • getOptionalString

      Optional<String> getOptionalString(String key)
      Return an Optional with the String associated to key, or an empty Optional is such key doesn't exist.
      Parameters:
      key - the key to lookup
      Returns:
      the Optional with the optional value associated to key
      Throws:
      ClassCastException - the value associated to key is not convertible to a String
    • getOptionalInt

      OptionalInt getOptionalInt(String key)
      Return an OptionalInt with the int associated to key, or an empty OptionalInt is such key doesn't exist.
      Parameters:
      key - the key to lookup
      Returns:
      the OptionalInt with the optional value associated to key
      Throws:
      ClassCastException - the value associated to key is not convertible to a int
    • getOptionalLong

      OptionalLong getOptionalLong(String key)
      Return an OptionalInt with the long associated to key, or an empty OptionalInt is such key doesn't exist.
      Parameters:
      key - the key to lookup
      Returns:
      the OptionalInt with the optional value associated to key
      Throws:
      ClassCastException - the value associated to key is not convertible to a long
    • getOptionalBoolean

      Optional<Boolean> getOptionalBoolean(String key)
      Return an Optional with the boolean associated to key, or an empty Optional is such key doesn't exist.
      Parameters:
      key - the key to lookup
      Returns:
      the Optional with the optional value associated to key
      Throws:
      ClassCastException - the value associated to key is not convertible to a boolean
    • getOptionalAs

      <T> Optional<T> getOptionalAs(String key, Class<T> type)
      Return an Optional with the RepresentationModel associated to key, or an empty Optional is such key doesn't exist.
      Parameters:
      key - the key to lookup
      Returns:
      the Optional with the optional value associated to key
      Throws:
      ClassCastException - the value associated to key is not convertible to a RepresentationModel
    • getViewData

      Map<String,Object> getViewData()
      Returns a Map with the model's view data. The use of typed accessors, such as getString(String) and getOptionalAs(String, Class), should be preferred.
      Returns:
      the view data associated with the model.