@Override
    public <T> T toTypedValue(String stringValue, Class<T> type) {
        if (stringValue==null || stringValue.equalsIgnoreCase("null")) {
            return null;
        }
        try {
            try {
                //with string constructor
                Constructor<T> constructor=type.getConstructor(String.class);
                T typedValue=constructor.newInstance(stringValue);
                return typedValue;
            } catch (NoSuchMethodException e) {
                //with noarg constructor and valueof
                T typedValue=type.newInstance();
                Method method=type.getMethod("valueOf", String.class);
                method.invoke(typedValue, stringValue);
                return typedValue;
           }
        } catch (InstantiationException e) {
           throw new ParameterConverterException("Error while converting value to object:"+stringValue, e);
        } catch (IllegalAccessException e) {
            throw new ParameterConverterException("Error while converting value to object:"+stringValue, e);
        } catch (SecurityException e) {
            throw new ParameterConverterException("Error while converting value to object:"+stringValue, e);
        } catch (NoSuchMethodException e) {
            throw new ParameterConverterException("Error while converting value to object:"+stringValue, e);
        } catch (IllegalArgumentException e) {
            throw new ParameterConverterException("Error while converting value to object:"+stringValue, e);
        } catch (InvocationTargetException e) {
            throw new ParameterConverterException("Error while converting value to object:"+stringValue, e);
        }
    }