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
DefaultVarExploderis aVarExploderimplementation 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
DefaultVarExploderbreaks down the object properties as follows:- All properties that contain a non-null return value will be included
- Getters or fields annotated with
UriTransientwill 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
VarNameannotation 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 aMapof name/value pairs.Collection<Object>getValues()Returns the properties of the source object aCollectionof 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:VarExploderReturns the properties of the source object aMapof name/value pairs.- Specified by:
getNameValuePairsin interfaceVarExploder- Returns:
- the name value pairs of the input
-
getValues
public Collection<Object> getValues() throws VarExploderException
Description copied from interface:VarExploderReturns the properties of the source object aCollectionof object values.- Specified by:
getValuesin interfaceVarExploder- Returns:
- Throws:
VarExploderException
-
-