/** * Converts String to Long. * * @param value * The String to be converted. * @return The converted Long value. */ public static Long stringToLong(String val) { return Long.valueOf(trim(val)); }
/** * Converts String to float. * * @param value * The String to be converted. * @return The converted Double value. */ public static Float stringToFloat(String val) { return Float.valueOf(trim(val)); }
/** * Converts String to Double. * * @param value * The String to be converted. * @return The converted Double value. */ public static Double stringToDouble(String val) { String v = trim(val); if (StringUtil.isNullOrEmpty(v)) { return null; } else { return Double.valueOf(v); } }
/** * Converts comma separated string to Set * * @param <T> * type of set * @param value * comma separated values. * @return The converted set with type <T>. */ public static <T> Set<T> stringToSet(String val, Class<T> type) { String[] tokens = trim(val).split(","); return Arrays.stream(tokens).map(t -> { return convert(t, type); }).collect(Collectors.toSet()); }
/** * Converts String to Integer. * * @param value * The String to be converted. * @return The converted Integer value. */ public static Integer stringToInteger(String val) { String v = trim(val); if (StringUtil.isNullOrEmpty(v)) { return null; } else { return Integer.valueOf(v); } }
/** * Converts comma separated string to List * * @param <T> * type of list * @param value * comma separated values. * @return The converted list with type <T>. */ public static <T> List<T> stringToList(String val, Class<T> type) { String[] tokens = trim(val).split(","); return Arrays.stream(tokens).map(t -> { return convert(t, type); }).collect(Collectors.toList()); }
/** * Converts String to float. * * @param value * The String to be converted. * @return The converted Double value. */ public static Float stringToFloat(String val) { return Float.valueOf(trim(val)); }
/** * Converts String to Long. * * @param value * The String to be converted. * @return The converted Long value. */ public static Long stringToLong(String val) { return Long.valueOf(trim(val)); }
/** * Converts String to Double. * * @param value * The String to be converted. * @return The converted Double value. */ public static Double stringToDouble(String val) { String v = trim(val); if (StringUtil.isNullOrEmpty(v)) { return null; } else { return Double.valueOf(v); } }
/** * Converts comma separated string to List * * @param <T> * type of list * @param value * comma separated values. * @return The converted list with type <T>. */ public static <T> List<T> stringToList(String val, Class<T> type) { String[] tokens = trim(val).split(","); return Arrays.stream(tokens).map(t -> { return convert(t, type); }).collect(Collectors.toList()); }
/** * Converts String to Integer. * * @param value * The String to be converted. * @return The converted Integer value. */ public static Integer stringToInteger(String val) { String v = trim(val); if (StringUtil.isNullOrEmpty(v)) { return null; } else { return Integer.valueOf(v); } }
/** * Converts comma separated string to Set * * @param <T> * type of set * @param value * comma separated values. * @return The converted set with type <T>. */ public static <T> Set<T> stringToSet(String val, Class<T> type) { String[] tokens = trim(val).split(","); return Arrays.stream(tokens).map(t -> { return convert(t, type); }).collect(Collectors.toSet()); }