jeudi 17 janvier 2019

How do I check that list was initialized with 0 elements in it?

For example:

public List<Integer> list = new ArrayList<>();

and how can I check through reflection that this list is empty and not null?

   for (final Field field : ReflectionUtils.getDeclaredFields(clazz))
            {
                if (List.class.isAssignableFrom(field.getType()))
                {
                   // TODO check whether the list is empty.
                }
            }





Aucun commentaire:

Enregistrer un commentaire