Skip to content

Commit

Permalink
Code review suggetions 1
Browse files Browse the repository at this point in the history
  • Loading branch information
wmedvede committed Nov 7, 2023
1 parent 81b91be commit 27d74a0
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ public static <T> Collection<T> convertToCollection(Object value, Class<T> clazz
* Converts a string into a list of objects
*
* @param <T>
* @param value object to be converted into list
* @param clazz the item target class
* @param value object to be converted into list
* @param clazz the item target class
* @param separator the separator of values
* @return a collection
*/
Expand Down Expand Up @@ -120,15 +120,15 @@ private static Method getConvertMethod(Class<?> clazz) {
* @return true if the given type corresponds to a java base type that has the method valueOf(String value).
*/
private static boolean isConvertibleFromStringJavaBaseType(Class<?> clazz) {
return clazz == Short.class || clazz == Integer.class || clazz == Long.class ||
return clazz == Short.class || clazz == Integer.class || clazz == Long.class || clazz == Byte.class ||
clazz == Float.class || clazz == Double.class ||
clazz == Boolean.class;
}

/**
* @return the value created by applying the static method valueOf(String) on the given class. We use this method on
* these base java types to ensure conversion continues working on code generated by the quarkus native build,
* since it was detected that valueOf is not discovered by reflection on these classes after the native build.
* these base java types to ensure conversion continues working on code generated by the quarkus native build,
* since it was detected that valueOf is not discovered by reflection on these classes after the native build.
*/
private static <T> T convertFromStringJavaBaseType(Class<T> clazz, String value) throws NumberFormatException {
if (clazz == Short.class) {
Expand All @@ -140,6 +140,9 @@ private static <T> T convertFromStringJavaBaseType(Class<T> clazz, String value)
if (clazz == Long.class) {
return (T) Long.valueOf(value);
}
if (clazz == Byte.class) {
return (T) Byte.valueOf(value);
}
if (clazz == Float.class) {
return (T) Float.valueOf(value);
}
Expand Down

0 comments on commit 27d74a0

Please sign in to comment.