We return a description of factory parameters in terms of an Param (or its superclass Parameter). This is a bit of a pain since it is hard to find a param entry by key; or sort out what the different utility methods do.
Often you end up writing the same for loops multiple times; or putting things in a Map<String,Param> just to make programming faster.
The attached class was combined from a bunch of uDig utility code from handling parameters and operates as a wrapper around a Param.
An example use is:
The expected type is passed in; simply to cut down on casting; if "host" is not available in the factory params it will not be blindly returned. In a similar manner the host "sample" value of localhost will be returned if the connectionParams does not contain an "host" entry. This method builds on Param.handle( connectionParams ).
Please note that the Param superclass Parameter has less helpful utility methods; it is my preference to move such things into this Params class rather then complicate the superclass.
The approach of a wrapper was taken rather then adding methods to DataUtilities.
- Params may not be the best name for the class - even the above code example has too many things named "param". Should use a plural form since we are wrapping a set of parameters. Ideas: Parameters, ConnectionParameters
- Note this is not Andrea's long standing request for a Java Bean; however this class could become a formal DynamicProxy (if we pass the connection parameter values in) or produce a BeanInfo for working with one of the commons bean classes which present a java map as a bean.