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 Detail

      • 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
      • 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
      • 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