Optional<String> (List<Object> list) { Optional<Object> first = list.stream().filter(obj -> obj instanceof String).findFirst(); return first.is<caret>Present() ? trimmed((String) first.get()) : Optional.empty(); }