src/main/java/js/http/encoder/QueryParametersParser.java
@SuppressWarnings("unchecked")
	private static <T> T asObject(String value, Type type) {
		if (value == null) {
			return (T) Types.getEmptyValue(type);
		}

		if (!Types.isArrayLike(type)) {
			if (!(type instanceof Class)) {
				throw new BugError("Generic value types are not supported.");
			}
			if (ConverterRegistry.hasType(type)) {
				return ConverterRegistry.getConverter().asObject(value, (Class<T>) type);
			}
			log.debug("Missing converter for query parameter of type |%s|.", type);
			return (T) Types.getEmptyValue(type);
		}

		// here we have an array/collection represented as comma separated primitives
		List<String> strings = Strings.split(value, ',');
		if (type == String[].class) {
			return (T) strings.toArray(new String[strings.size()]);
		}
		if (Types.isKindOf(type, Collection.class)) {
			Type collectionType = type;
			Class<?> itemType = String.class;
			if (type instanceof ParameterizedType) {
				collectionType = ((ParameterizedType) type).getRawType();
				itemType = (Class<?>) ((ParameterizedType) type).getActualTypeArguments()[0];
			}
			Collection<Object> collection = Classes.newCollection(collectionType);
			Converter converter = ConverterRegistry.getConverter();
			for (String s : strings) {
				collection.add(converter.asObject(s.trim(), itemType));
			}
			return (T) collection;
		}

		throw new BugError("Type not supported |%s|.", type);
	}
@SuppressWarnings("unchecked")
	private static <T> T asObject(String value, Type type) {
		if (value == null) {
			return (T) Types.getEmptyValue(type);
		}

		if (!Types.isArrayLike(type)) {
			if (!(type instanceof Class)) {
				throw new BugError("Generic value types are not supported.");
			}
			if (ConverterRegistry.hasType(type)) {
				return ConverterRegistry.getConverter().asObject(value, (Class<T>) type);
			}
			log.debug("Missing converter for query parameter of type |%s|.", type);
			return (T) Types.getEmptyValue(type);
		}

		// here we have an array/collection represented as comma separated primitives
		List<String> strings = Strings.split(value, ',');
		if (type == String[].class) {
			return (T) strings.toArray(new String[strings.size()]);
		}
		if (Types.isKindOf(type, Collection.class)) {
			Type collectionType = type;
			Class<?> itemType = String.class;
			if (type instanceof ParameterizedType) {
				collectionType = ((ParameterizedType) type).getRawType();
				itemType = (Class<?>) ((ParameterizedType) type).getActualTypeArguments()[0];
			}
			Collection<Object> collection = Classes.newCollection(collectionType);
			Converter converter = ConverterRegistry.getConverter();
			for (String s : strings) {
				collection.add(converter.asObject(s.trim(), itemType));
			}
			return (T) collection;
		}

		throw new BugError("Type not supported |%s|.", type);
	}
Helper method to convert string parameter to an instance of a given type. Requested <code>type</code> should be a value
type as accepted by converter package or an array / collection of value types. In the later case <code>value</code>
should be a comma separated string of items. If given <code>value</code> is null returns an empty value as defined by
{@link Types#getEmptyValue(Type)}.

@param value parameter value, possible null,
@param type parameter type.
@param <T> instance type.
@return newly created parameter type instance.
@throws ConverterException if string value cannot be converted to requested type.
@throws BugError if type is generic and is not an array like.