You can create a util method that converts any collection to a java list
public static List<?> convertObjectToList(Object obj) {
List<?> list = new ArrayList<>();
if (obj.getClass().isArray()) {
list = Arrays.asList((Object[])obj);
} else if (obj instanceof Collection) {
list = new ArrayList<>((Collection<?>)obj);
}
return list;
}
you can also mix with this validation below:
public static boolean isCollection(Object obj) {
return obj.getClass().isArray() || obj instanceof Collection;
}