Interface Variables


public interface Variables
Holds a set of name/value pairs where each value can be a String or a List<String> or a Map<String, String>.
  • Method Summary

    Modifier and Type
    Method
    Description
    Populates with a JSON object: null are conserved JsonArray is converted to List<String> JsonObject is converted to Map<String, String> any other value is converted to a string Note that nested JSON elements are converted to a string, so { "user": { "first_name": "John", "last_name": "Doe", "address" : { "city": "Paris", etc... } } } flattens the JSON "address" to the string "{\"city\":\"Paris\",etc...}".
     
    get(String name)
     
     
    getMap(String name)
     
     
     
    set(String name, String value)
    Set a single variable.
    set(String name, List<String> value)
    Set a list variable.
    set(String name, Map<String,String> value)
    Set a map variable.
    default Variables
    Like addAll(JsonObject) but overwrites previous variables.
    static Variables
     
    static Variables
    Create an instance populated from a JSON object: null are conserved JsonArray is converted to List<String> JsonObject is converted to Map<String, String> any other value is converted to a string Note that nested JSON elements are converted to a string, so { "user": { "first_name": "John", "last_name": "Doe", "address" : { "city": "Paris", etc... } } } flattens the JSON "address" to the string "{\"city\":\"Paris\",etc...}".
  • Method Details

    • variables

      static Variables variables()
      Returns:
      an empty instance
    • variables

      static Variables variables(JsonObject json)
      Create an instance populated from a JSON object:
      • null are conserved
      • JsonArray is converted to List<String>
      • JsonObject is converted to Map<String, String>
      • any other value is converted to a string
      Note that nested JSON elements are converted to a string, so { "user": { "first_name": "John", "last_name": "Doe", "address" : { "city": "Paris", etc... } } } flattens the JSON "address" to the string "{\"city\":\"Paris\",etc...}".
      Parameters:
      json - the json that populates the returned variables
      Returns:
      an instance populated from a JSON object
    • set

      Variables set(String name, String value)
      Set a single variable.
      Parameters:
      name - the variable name
      value - the variable value
      Returns:
      a reference to this, so the API can be used fluently
    • set

      Variables set(String name, List<String> value)
      Set a list variable.
      Parameters:
      name - the variable name
      value - the variable value
      Returns:
      a reference to this, so the API can be used fluently
    • set

      Variables set(String name, Map<String,String> value)
      Set a map variable.
      Parameters:
      name - the variable name
      value - the variable value
      Returns:
      a reference to this, so the API can be used fluently
    • setAll

      default Variables setAll(JsonObject json)
      Like addAll(JsonObject) but overwrites previous variables.
    • addAll

      Variables addAll(JsonObject json)
      Populates with a JSON object:
      • null are conserved
      • JsonArray is converted to List<String>
      • JsonObject is converted to Map<String, String>
      • any other value is converted to a string
      Note that nested JSON elements are converted to a string, so { "user": { "first_name": "John", "last_name": "Doe", "address" : { "city": "Paris", etc... } } } flattens the JSON "address" to the string "{\"city\":\"Paris\",etc...}".
      Parameters:
      json - the json that populates the returned variables
      Returns:
      a reference to this, so the API can be used fluently
    • clear

      Variables clear()
    • names

      Set<String> names()
      Returns:
      the set of variable names
    • get

      Object get(String name)
      Returns:
      the value of the variable name
    • getSingle

      String getSingle(String name)
      Returns:
      the single value of the variable name
    • getList

      List<String> getList(String name)
      Returns:
      the list value of the variable name
    • getMap

      Map<String,String> getMap(String name)
      Returns:
      the map value of the variable name