Class GenericJsonConfigurationHelper<J>
- java.lang.Object
-
- net.obvj.confectory.internal.helper.GenericJsonConfigurationHelper<J>
-
- All Implemented Interfaces:
ConfigurationDataRetriever<J>,ConfigurationHelper<J>
- Direct Known Subclasses:
JsonSmartConfigurationHelper
public abstract class GenericJsonConfigurationHelper<J> extends Object implements ConfigurationHelper<J>
A generic Configuration Helper that retrieves data from a JSON document, with JSONPath capabilities.- Since:
- 0.3.0
- Author:
- oswaldo.bapvic.jr (Oswaldo Junior)
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Objectget(String jsonPath)Returns the object associated with the specified @code jsonPath} in the JSON document in context.JgetBean()Returns the configuration bean used by this data retriever, typically for manual handling and/or troubleshooting purposes.BooleangetBoolean(String jsonPath)Returns theBooleanobject associated with the specifiedjsonPathin theJsonNodein context, provided that the expression returns a single element that can be mapped toboolean.DoublegetDouble(String jsonPath)Returns theDoubleobject associated with the specifiedjsonPathin theJsonNodein context, provided that the expression returns a single element that can be mapped todouble.IntegergetInteger(String jsonPath)Returns theIntegerobject associated with the specifiedjsonPathin theJsonNodein context, provided that the expression returns a single element that can be mapped toint.LonggetLong(String jsonPath)Returns theLongobject associated with the specifiedjsonPathin theJsonNodein context, provided that the expression returns a single element that can be mapped tolong.BooleangetMandatoryBoolean(String jsonPath)Returns theBooleanobject associated with the specifiedjsonPathin theJsonNodein context, provided that the expression returns a single element that can be mapped toboolean.DoublegetMandatoryDouble(String jsonPath)Returns theDoubleobject associated with the specifiedjsonPathin theJsonNodein context, provided that the expression returns a single element that can be mapped todouble.IntegergetMandatoryInteger(String jsonPath)Returns theIntegerobject associated with the specifiedjsonPathin theJsonNodein context, provided that the expression returns a single element that can be mapped toint.LonggetMandatoryLong(String jsonPath)Returns theLongobject associated with the specifiedjsonPathin theJsonNodein context, provided that the expression returns a single element that can be mapped tolong.StringgetMandatoryString(String jsonPath)Returns theStringobject associated with the specifiedjsonPathin theJsonNodein context, provided that the expression returns a single element.StringgetString(String jsonPath)Returns theStringobject associated with the specifiedjsonPathin theJsonNodein context, provided that the expression returns a single element.-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.obvj.confectory.ConfigurationDataRetriever
getAsString
-
Methods inherited from interface net.obvj.confectory.internal.helper.ConfigurationHelper
configurationMerger
-
-
-
-
Method Detail
-
getBean
public J getBean()
Description copied from interface:ConfigurationDataRetrieverReturns the configuration bean used by this data retriever, typically for manual handling and/or troubleshooting purposes.- Specified by:
getBeanin interfaceConfigurationDataRetriever<J>- Returns:
- the JSON document in context
-
getBoolean
public Boolean getBoolean(String jsonPath)
Returns theBooleanobject associated with the specifiedjsonPathin theJsonNodein context, provided that the expression returns a single element that can be mapped toboolean.- Specified by:
getBooleanin interfaceConfigurationDataRetriever<J>- Parameters:
jsonPath- the path to read- Returns:
- the
Booleanobject associated with the specifiedjsonPath;nullif the path is not found - Throws:
IllegalArgumentException- ifjsonPathis null or emptycom.jayway.jsonpath.InvalidPathException- if thejsonPathexpression is not validConfigurationException- if thejsonPathexpression returns more than a single elementClassCastException- if thejsonPathresult cannot be assigned toboolean
-
getMandatoryBoolean
public Boolean getMandatoryBoolean(String jsonPath)
Returns theBooleanobject associated with the specifiedjsonPathin theJsonNodein context, provided that the expression returns a single element that can be mapped toboolean.- Specified by:
getMandatoryBooleanin interfaceConfigurationDataRetriever<J>- Parameters:
jsonPath- the path to read- Returns:
- the
Booleanobject associated with the specifiedjsonPath; nevernull - Throws:
IllegalArgumentException- ifjsonPathis null or emptycom.jayway.jsonpath.InvalidPathException- if thejsonPathexpression is not validConfigurationException- if not value found or thejsonPathexpression returns more than a single elementClassCastException- if thejsonPathresult cannot be assigned toboolean- Since:
- 0.4.0
-
getInteger
public Integer getInteger(String jsonPath)
Returns theIntegerobject associated with the specifiedjsonPathin theJsonNodein context, provided that the expression returns a single element that can be mapped toint.- Specified by:
getIntegerin interfaceConfigurationDataRetriever<J>- Parameters:
jsonPath- the path to read- Returns:
- the
Integerobject associated with the specifiedjsonPath;nullif the path is not found - Throws:
IllegalArgumentException- ifjsonPathis null or emptycom.jayway.jsonpath.InvalidPathException- if thejsonPathexpression is not validConfigurationException- if thejsonPathexpression returns more than a single elementClassCastException- if thejsonPathresult cannot be assigned toint
-
getMandatoryInteger
public Integer getMandatoryInteger(String jsonPath)
Returns theIntegerobject associated with the specifiedjsonPathin theJsonNodein context, provided that the expression returns a single element that can be mapped toint.- Specified by:
getMandatoryIntegerin interfaceConfigurationDataRetriever<J>- Parameters:
jsonPath- the path to read- Returns:
- the
Integerobject associated with the specifiedjsonPath; nevernull - Throws:
IllegalArgumentException- ifjsonPathis null or emptycom.jayway.jsonpath.InvalidPathException- if thejsonPathexpression is not validConfigurationException- if not value found or thejsonPathexpression returns more than a single elementClassCastException- if thejsonPathresult cannot be assigned toint- Since:
- 0.4.0
-
getLong
public Long getLong(String jsonPath)
Returns theLongobject associated with the specifiedjsonPathin theJsonNodein context, provided that the expression returns a single element that can be mapped tolong.- Specified by:
getLongin interfaceConfigurationDataRetriever<J>- Parameters:
jsonPath- the path to read- Returns:
- the
Longobject associated with the specifiedjsonPath;nullif the path is not found - Throws:
IllegalArgumentException- ifjsonPathis null or emptycom.jayway.jsonpath.InvalidPathException- if thejsonPathexpression is not validConfigurationException- if thejsonPathexpression returns more than a single elementClassCastException- if thejsonPathresult cannot be assigned tolong
-
getMandatoryLong
public Long getMandatoryLong(String jsonPath)
Returns theLongobject associated with the specifiedjsonPathin theJsonNodein context, provided that the expression returns a single element that can be mapped tolong.- Specified by:
getMandatoryLongin interfaceConfigurationDataRetriever<J>- Parameters:
jsonPath- the path to read- Returns:
- the
Longobject associated with the specifiedjsonPath; nevernull - Throws:
IllegalArgumentException- ifjsonPathis null or emptycom.jayway.jsonpath.InvalidPathException- if thejsonPathexpression is not validConfigurationException- if not value found or thejsonPathexpression returns more than a single elementClassCastException- if thejsonPathresult cannot be assigned tolong- Since:
- 0.4.0
-
getDouble
public Double getDouble(String jsonPath)
Returns theDoubleobject associated with the specifiedjsonPathin theJsonNodein context, provided that the expression returns a single element that can be mapped todouble.- Specified by:
getDoublein interfaceConfigurationDataRetriever<J>- Parameters:
jsonPath- the path to read- Returns:
- the
Doubleobject associated with the specifiedjsonPath;nullif the path is not found - Throws:
IllegalArgumentException- ifjsonPathis null or emptycom.jayway.jsonpath.InvalidPathException- if thejsonPathexpression is not validConfigurationException- if thejsonPathexpression returns more than a single elementClassCastException- if thejsonPathresult cannot be assigned todouble
-
getMandatoryDouble
public Double getMandatoryDouble(String jsonPath)
Returns theDoubleobject associated with the specifiedjsonPathin theJsonNodein context, provided that the expression returns a single element that can be mapped todouble.- Specified by:
getMandatoryDoublein interfaceConfigurationDataRetriever<J>- Parameters:
jsonPath- the path to read- Returns:
- the
Doubleobject associated with the specifiedjsonPath; nevernull - Throws:
IllegalArgumentException- ifjsonPathis null or emptycom.jayway.jsonpath.InvalidPathException- if thejsonPathexpression is not validConfigurationException- if not value found or thejsonPathexpression returns more than a single elementClassCastException- if thejsonPathresult cannot be assigned todouble- Since:
- 0.4.0
-
getString
public String getString(String jsonPath)
Returns theStringobject associated with the specifiedjsonPathin theJsonNodein context, provided that the expression returns a single element.- Specified by:
getStringin interfaceConfigurationDataRetriever<J>- Parameters:
jsonPath- the path to read- Returns:
- the
Stringobject associated with the specifiedjsonPath;nullif the path is not found - Throws:
IllegalArgumentException- ifjsonPathis null or emptycom.jayway.jsonpath.InvalidPathException- if thejsonPathexpression is not validConfigurationException- if thejsonPathexpression returns more than a single element
-
getMandatoryString
public String getMandatoryString(String jsonPath)
Returns theStringobject associated with the specifiedjsonPathin theJsonNodein context, provided that the expression returns a single element.- Specified by:
getMandatoryStringin interfaceConfigurationDataRetriever<J>- Parameters:
jsonPath- the path to read- Returns:
- the
Stringvalue associated with the specifiedjsonPath; nevernull - Throws:
IllegalArgumentException- ifjsonPathis null or emptycom.jayway.jsonpath.InvalidPathException- if thejsonPathexpression is not validConfigurationException- if not value found or thejsonPathexpression 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:
getin interfaceConfigurationDataRetriever<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- ifjsonPathis null or emptycom.jayway.jsonpath.InvalidPathException- if thejsonPathexpression is not valid- Since:
- 1.2.0
-
-