Package com.damnhandy.uri.template
Class DefaultVarExploder
- java.lang.Object
-
- com.damnhandy.uri.template.DefaultVarExploder
-
- All Implemented Interfaces:
VarExploder
public class DefaultVarExploder extends Object implements VarExploder
The
DefaultVarExploder
is aVarExploder
implementation that takes in a Java object and extracts the properties for use in a URI Template. Given the following URI expression:/mapper{?address*}
And this Java object for an address:
Address address = new Address(); address.setState("CA"); address.setCity("Newport Beach"); String result = UriTemplate.fromTemplate("/mapper{?address*}").set("address", address).expand();
The expanded URI will be:
/mapper?city=Newport%20Beach&state=CA
The
DefaultVarExploder
breaks down the object properties as follows:- All properties that contain a non-null return value will be included
- Getters or fields annotated with
UriTransient
will NOT included in the list - By default, the property name is used as the label in the URI. This can be overridden by
placing the
VarName
annotation on the field or getter method and specifying a name. - Field level annotation take priority of getter annotations
- Since:
- 1.0
- Version:
- $Revision: 1.1 $
- Author:
- Ryan J. McDonough
- See Also:
VarName
,UriTransient
,VarExploder
-
-
Constructor Summary
Constructors Constructor Description DefaultVarExploder(Object source)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Map<String,Object>
getNameValuePairs()
Returns the properties of the source object aMap
of name/value pairs.Collection<Object>
getValues()
Returns the properties of the source object aCollection
of object values.
-
-
-
Constructor Detail
-
DefaultVarExploder
public DefaultVarExploder(Object source) throws VarExploderException
- Parameters:
source
- the Object to explode- Throws:
VarExploderException
-
-
Method Detail
-
getNameValuePairs
public Map<String,Object> getNameValuePairs()
Description copied from interface:VarExploder
Returns the properties of the source object aMap
of name/value pairs.- Specified by:
getNameValuePairs
in interfaceVarExploder
- Returns:
- the name value pairs of the input
-
getValues
public Collection<Object> getValues() throws VarExploderException
Description copied from interface:VarExploder
Returns the properties of the source object aCollection
of object values.- Specified by:
getValues
in interfaceVarExploder
- Returns:
- Throws:
VarExploderException
-
-