Interface VariablesRequestContextAddon<R extends RequestContext<?>>

All Known Implementing Classes:
SpincastVariablesRequestContextAddon

public interface VariablesRequestContextAddon<R extends RequestContext<?>>
Methods to read and write request scoped variables.
  • Method Summary

    Modifier and Type
    Method
    Description
    get(String key)
    Gets the specified request scoped variable.
    <T> T
    get(String key, com.google.inject.Key<T> typeKey)
    Gets the specified request scoped variable as the specified Key.
    <T> T
    get(String key, Class<T> clazz)
    Gets the specified request scoped variable as the specified class.
    Gets all the request scoped variables.
    Gets the specified request scoped variable as JsonObject.
    Gets the specified request scoped variable as a String.
    void
    Removes a request scoped variable.
    void
    set(String key, Object obj)
    Adds a request scoped variable.
    void
    set(Map<String,Object> variables)
    Adds request scoped variables.
  • Method Details

    • set

      void set(String key, Object obj)
      Adds a request scoped variable.

      It is recommended that you prefixe the name of the key with the name of your class (for example : this.getClass().getName()), so it doesn't clash with other keys!

      If the variable already exists, it is overwritten.

    • set

      void set(Map<String,Object> variables)
      Adds request scoped variables.

      It is recommended that you prefixe the name of the keys with the name of your class (for example : this.getClass().getName()), so they don't clash with other keys!

      If some variables already exist, they are overwritten.

    • getAll

      Map<String,Object> getAll()
      Gets all the request scoped variables. The map is immutable.
    • get

      Object get(String key)
      Gets the specified request scoped variable.
    • get

      <T> T get(String key, Class<T> clazz)
      Gets the specified request scoped variable as the specified class.
      Throws:
      an - exception is the object is not of the specified class.
    • get

      <T> T get(String key, com.google.inject.Key<T> typeKey)
      Gets the specified request scoped variable as the specified Key.
      Throws:
      an - exception is the object is not of the specified Key.
    • getAsJsonObject

      JsonObject getAsJsonObject(String key)
      Gets the specified request scoped variable as JsonObject.
    • getAsString

      String getAsString(String key)
      Gets the specified request scoped variable as a String. toString will be called on the Object.
    • remove

      void remove(String key)
      Removes a request scoped variable. Note: Spincast uses some request scoped variables for internal purposes. Do not try to remove all variables!