void (String[] args) { final Class<?> cls = ArrayList.class; for (Field f : cls.getFields()) { final String fieldType = getFoo(f.getType()).orElseGet(() -> getBar(f).<caret>orElse(null)); if (fieldType != null) { System.out.println(fieldType); } } }