public static Object convertStringToWrapper(String str,Class<?> wrapper){
  log.trace("String: {} to wrapper: {}",str,wrapper);
  if (wrapper.equals(String.class)) {
    return str;
  }
 else   if (wrapper.equals(Boolean.class)) {
    return Boolean.valueOf(str);
  }
 else   if (wrapper.equals(Double.class)) {
    return Double.valueOf(str);
  }
 else   if (wrapper.equals(Long.class)) {
    return Long.valueOf(str);
  }
 else   if (wrapper.equals(Float.class)) {
    return Float.valueOf(str);
  }
 else   if (wrapper.equals(Integer.class)) {
    return Integer.valueOf(str);
  }
 else   if (wrapper.equals(Short.class)) {
    return Short.valueOf(str);
  }
 else   if (wrapper.equals(Byte.class)) {
    return Byte.valueOf(str);
  }
  return null;
}

public static Object convertStringToWrapper ( String str , Class < ? > wrapper ) { log . trace ( "String: {} to wrapper: {}" , str , wrapper ) ; if ( wrapper . equals ( String . class ) ) { return str ; } else if ( wrapper . equals ( Boolean . class ) ) { return Boolean . valueOf ( str ) ; } else if ( wrapper . equals ( Double . class ) ) { return Double . valueOf ( str ) ; } else if ( wrapper . equals ( Long . class ) ) { return Long . valueOf ( str ) ; } else if ( wrapper . equals ( Float . class ) ) { return Float . valueOf ( str ) ; } else if ( wrapper . equals ( Integer . class ) ) { return Integer . valueOf ( str ) ; } else if ( wrapper . equals ( Short . class ) ) { return Short . valueOf ( str ) ; } else if ( wrapper . equals ( Byte . class ) ) { return Byte . valueOf ( str ) ; } return null ; }
convert string to primitive wrapper like boolean or float
