extensions/resource/src/main/java/uk/co/tfd/sm/util/http/RequestUtils.java
public static Object toValue(String name, Object value) {
		String[] parts = StringUtils.split(name, "@", 2);
		String fieldName = null;
		String fieldType = "String";
		if (parts.length == 2) {
			fieldType = parts[1];
			fieldName = parts[0];
		} else if (parts.length == 1) {
			fieldName = parts[0];
		} else {
			throw new IllegalArgumentException("Invalid property name");
		}
		try {
			int l = Array.getLength(value);
			RequestParameterType<?> rpt = TYPES.get(fieldType);
			if (rpt == null) {
				rpt = TYPES.get(RequestParameterType.STRING);
			}
			if (!fieldName.endsWith("[]") && l == 1) {
				return rpt.newInstance(Array.get(value, 0));
			}
			Class<?> componentType = rpt.getComponentType();
			Object[] a = (Object[]) Array.newInstance(componentType, l);
			for (int i = 0; i < l; i++) {
				a[i] = rpt.newInstance(Array.get(value, i));
			}
			return a;
		} catch (IllegalArgumentException e) {
			RequestParameterType<?> rpt = TYPES.get(fieldType);
			if (rpt == null) {
				rpt = TYPES.get(RequestParameterType.STRING);
			}
			return rpt.newInstance(value);
		}
	}
public static Object toValue(String name, Object value) {
		String[] parts = StringUtils.split(name, "@", 2);
		String fieldName = null;
		String fieldType = "String";
		if (parts.length == 2) {
			fieldType = parts[1];
			fieldName = parts[0];
		} else if (parts.length == 1) {
			fieldName = parts[0];
		} else {
			throw new IllegalArgumentException("Invalid property name");
		}
		try {
			int l = Array.getLength(value);
			RequestParameterType<?> rpt = TYPES.get(fieldType);
			if (rpt == null) {
				rpt = TYPES.get(RequestParameterType.STRING);
			}
			if (!fieldName.endsWith("[]") && l == 1) {
				return rpt.newInstance(Array.get(value, 0));
			}
			Class<?> componentType = rpt.getComponentType();
			Object[] a = (Object[]) Array.newInstance(componentType, l);
			for (int i = 0; i < l; i++) {
				a[i] = rpt.newInstance(Array.get(value, i));
			}
			return a;
		} catch (IllegalArgumentException e) {
			RequestParameterType<?> rpt = TYPES.get(fieldType);
			if (rpt == null) {
				rpt = TYPES.get(RequestParameterType.STRING);
			}
			return rpt.newInstance(value);
		}
	}
public static Object toValue ( String name , Object value ) { String [ ] parts = StringUtils . split ( name , "@" , 2 ) ; String fieldName = null ; String fieldType = "String" ; if ( parts . length == 2 ) { fieldType = parts [ 1 ] ; fieldName = parts [ 0 ] ; } else if ( parts . length == 1 ) { fieldName = parts [ 0 ] ; } else { throw new IllegalArgumentException ( "Invalid property name" ) ; } try { int l = Array . getLength ( value ) ; RequestParameterType < ? > rpt = TYPES . get ( fieldType ) ; if ( rpt == null ) { rpt = TYPES . get ( RequestParameterType . STRING ) ; } if ( ! fieldName . endsWith ( "[]" ) && l == 1 ) { return rpt . newInstance ( Array . get ( value , 0 ) ) ; } Class < ? > componentType = rpt . getComponentType ( ) ; Object [ ] a = ( Object [ ] ) Array . newInstance ( componentType , l ) ; for ( int i = 0 ; i < l ; i ++ ) { a [ i ] = rpt . newInstance ( Array . get ( value , i ) ) ; } return a ; } catch ( IllegalArgumentException e ) { RequestParameterType < ? > rpt = TYPES . get ( fieldType ) ; if ( rpt == null ) { rpt = TYPES . get ( RequestParameterType . STRING ) ; } return rpt . newInstance ( value ) ; } }
Creates the most suitable type.

@param name
the name. Types are specified as name@Type where Type is the
name of the type. If the name ends with a [] the type is
forced to be an array.
@param value
the value the value. If its an array, the type is assumed to
be an array provided there is more than one element. If there
is one element and the name ends with [] an array is created,
otherwise a scalar is created.
@return an instance
Creates the most suitable type .