Class GenericJsonConfigurationHelper<J>

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Object get​(String jsonPath)
      Returns the object associated with the specified @code jsonPath} in the JSON document in context.
      J getBean()
      Returns the configuration bean used by this data retriever, typically for manual handling and/or troubleshooting purposes.
      Boolean getBoolean​(String jsonPath)
      Returns the Boolean object associated with the specified jsonPath in the JsonNode in context, provided that the expression returns a single element that can be mapped to boolean.
      Double getDouble​(String jsonPath)
      Returns the Double object associated with the specified jsonPath in the JsonNode in context, provided that the expression returns a single element that can be mapped to double.
      Integer getInteger​(String jsonPath)
      Returns the Integer object associated with the specified jsonPath in the JsonNode in context, provided that the expression returns a single element that can be mapped to int.
      Long getLong​(String jsonPath)
      Returns the Long object associated with the specified jsonPath in the JsonNode in context, provided that the expression returns a single element that can be mapped to long.
      Boolean getMandatoryBoolean​(String jsonPath)
      Returns the Boolean object associated with the specified jsonPath in the JsonNode in context, provided that the expression returns a single element that can be mapped to boolean.
      Double getMandatoryDouble​(String jsonPath)
      Returns the Double object associated with the specified jsonPath in the JsonNode in context, provided that the expression returns a single element that can be mapped to double.
      Integer getMandatoryInteger​(String jsonPath)
      Returns the Integer object associated with the specified jsonPath in the JsonNode in context, provided that the expression returns a single element that can be mapped to int.
      Long getMandatoryLong​(String jsonPath)
      Returns the Long object associated with the specified jsonPath in the JsonNode in context, provided that the expression returns a single element that can be mapped to long.
      String getMandatoryString​(String jsonPath)
      Returns the String object associated with the specified jsonPath in the JsonNode in context, provided that the expression returns a single element.
      String getString​(String jsonPath)
      Returns the String object associated with the specified jsonPath in the JsonNode in context, provided that the expression returns a single element.
    • Method Detail

      • getBean

        public J getBean()
        Description copied from interface: ConfigurationDataRetriever
        Returns the configuration bean used by this data retriever, typically for manual handling and/or troubleshooting purposes.
        Specified by:
        getBean in interface ConfigurationDataRetriever<J>
        Returns:
        the JSON document in context
      • getBoolean

        public Boolean getBoolean​(String jsonPath)
        Returns the Boolean object associated with the specified jsonPath in the JsonNode in context, provided that the expression returns a single element that can be mapped to boolean.
        Specified by:
        getBoolean in interface ConfigurationDataRetriever<J>
        Parameters:
        jsonPath - the path to read
        Returns:
        the Boolean object associated with the specified jsonPath; null if the path is not found
        Throws:
        IllegalArgumentException - if jsonPath is null or empty
        com.jayway.jsonpath.InvalidPathException - if the jsonPath expression is not valid
        ConfigurationException - if the jsonPath expression returns more than a single element
        ClassCastException - if the jsonPath result cannot be assigned to boolean
      • getMandatoryBoolean

        public Boolean getMandatoryBoolean​(String jsonPath)
        Returns the Boolean object associated with the specified jsonPath in the JsonNode in context, provided that the expression returns a single element that can be mapped to boolean.
        Specified by:
        getMandatoryBoolean in interface ConfigurationDataRetriever<J>
        Parameters:
        jsonPath - the path to read
        Returns:
        the Boolean object associated with the specified jsonPath; never null
        Throws:
        IllegalArgumentException - if jsonPath is null or empty
        com.jayway.jsonpath.InvalidPathException - if the jsonPath expression is not valid
        ConfigurationException - if not value found or the jsonPath expression returns more than a single element
        ClassCastException - if the jsonPath result cannot be assigned to boolean
        Since:
        0.4.0
      • getInteger

        public Integer getInteger​(String jsonPath)
        Returns the Integer object associated with the specified jsonPath in the JsonNode in context, provided that the expression returns a single element that can be mapped to int.
        Specified by:
        getInteger in interface ConfigurationDataRetriever<J>
        Parameters:
        jsonPath - the path to read
        Returns:
        the Integer object associated with the specified jsonPath; null if the path is not found
        Throws:
        IllegalArgumentException - if jsonPath is null or empty
        com.jayway.jsonpath.InvalidPathException - if the jsonPath expression is not valid
        ConfigurationException - if the jsonPath expression returns more than a single element
        ClassCastException - if the jsonPath result cannot be assigned to int
      • getMandatoryInteger

        public Integer getMandatoryInteger​(String jsonPath)
        Returns the Integer object associated with the specified jsonPath in the JsonNode in context, provided that the expression returns a single element that can be mapped to int.
        Specified by:
        getMandatoryInteger in interface ConfigurationDataRetriever<J>
        Parameters:
        jsonPath - the path to read
        Returns:
        the Integer object associated with the specified jsonPath; never null
        Throws:
        IllegalArgumentException - if jsonPath is null or empty
        com.jayway.jsonpath.InvalidPathException - if the jsonPath expression is not valid
        ConfigurationException - if not value found or the jsonPath expression returns more than a single element
        ClassCastException - if the jsonPath result cannot be assigned to int
        Since:
        0.4.0
      • getLong

        public Long getLong​(String jsonPath)
        Returns the Long object associated with the specified jsonPath in the JsonNode in context, provided that the expression returns a single element that can be mapped to long.
        Specified by:
        getLong in interface ConfigurationDataRetriever<J>
        Parameters:
        jsonPath - the path to read
        Returns:
        the Long object associated with the specified jsonPath; null if the path is not found
        Throws:
        IllegalArgumentException - if jsonPath is null or empty
        com.jayway.jsonpath.InvalidPathException - if the jsonPath expression is not valid
        ConfigurationException - if the jsonPath expression returns more than a single element
        ClassCastException - if the jsonPath result cannot be assigned to long
      • getMandatoryLong

        public Long getMandatoryLong​(String jsonPath)
        Returns the Long object associated with the specified jsonPath in the JsonNode in context, provided that the expression returns a single element that can be mapped to long.
        Specified by:
        getMandatoryLong in interface ConfigurationDataRetriever<J>
        Parameters:
        jsonPath - the path to read
        Returns:
        the Long object associated with the specified jsonPath; never null
        Throws:
        IllegalArgumentException - if jsonPath is null or empty
        com.jayway.jsonpath.InvalidPathException - if the jsonPath expression is not valid
        ConfigurationException - if not value found or the jsonPath expression returns more than a single element
        ClassCastException - if the jsonPath result cannot be assigned to long
        Since:
        0.4.0
      • getDouble

        public Double getDouble​(String jsonPath)
        Returns the Double object associated with the specified jsonPath in the JsonNode in context, provided that the expression returns a single element that can be mapped to double.
        Specified by:
        getDouble in interface ConfigurationDataRetriever<J>
        Parameters:
        jsonPath - the path to read
        Returns:
        the Double object associated with the specified jsonPath; null if the path is not found
        Throws:
        IllegalArgumentException - if jsonPath is null or empty
        com.jayway.jsonpath.InvalidPathException - if the jsonPath expression is not valid
        ConfigurationException - if the jsonPath expression returns more than a single element
        ClassCastException - if the jsonPath result cannot be assigned to double
      • getMandatoryDouble

        public Double getMandatoryDouble​(String jsonPath)
        Returns the Double object associated with the specified jsonPath in the JsonNode in context, provided that the expression returns a single element that can be mapped to double.
        Specified by:
        getMandatoryDouble in interface ConfigurationDataRetriever<J>
        Parameters:
        jsonPath - the path to read
        Returns:
        the Double object associated with the specified jsonPath; never null
        Throws:
        IllegalArgumentException - if jsonPath is null or empty
        com.jayway.jsonpath.InvalidPathException - if the jsonPath expression is not valid
        ConfigurationException - if not value found or the jsonPath expression returns more than a single element
        ClassCastException - if the jsonPath result cannot be assigned to double
        Since:
        0.4.0
      • getString

        public String getString​(String jsonPath)
        Returns the String object associated with the specified jsonPath in the JsonNode in context, provided that the expression returns a single element.
        Specified by:
        getString in interface ConfigurationDataRetriever<J>
        Parameters:
        jsonPath - the path to read
        Returns:
        the String object associated with the specified jsonPath; null if the path is not found
        Throws:
        IllegalArgumentException - if jsonPath is null or empty
        com.jayway.jsonpath.InvalidPathException - if the jsonPath expression is not valid
        ConfigurationException - if the jsonPath expression returns more than a single element
      • getMandatoryString

        public String getMandatoryString​(String jsonPath)
        Returns the String object associated with the specified jsonPath in the JsonNode in context, provided that the expression returns a single element.
        Specified by:
        getMandatoryString in interface ConfigurationDataRetriever<J>
        Parameters:
        jsonPath - the path to read
        Returns:
        the String value associated with the specified jsonPath; never null
        Throws:
        IllegalArgumentException - if jsonPath is null or empty
        com.jayway.jsonpath.InvalidPathException - if the jsonPath expression is not valid
        ConfigurationException - if not value found or the jsonPath expression returns more than a single element
        Since:
        0.4.0
      • get

        public Object get​(String jsonPath)
        Returns the object associated with the specified @code jsonPath} in the JSON document in context.

        Note: The actual return type may vary depending on the JSON implementation, but usually it should be an array.

        Specified by:
        get in interface ConfigurationDataRetriever<J>
        Parameters:
        jsonPath - the path to read
        Returns:
        the object associated with the specified key; or an empty array if the path is not found
        Throws:
        IllegalArgumentException - if jsonPath is null or empty
        com.jayway.jsonpath.InvalidPathException - if the jsonPath expression is not valid
        Since:
        1.2.0