我需要从Rel值为href()
的链接列表中的String
返回值。
class Links{
String rel;
String href;
}
class 2{
List<Links> links
}
以下代码正在执行,但看起来并不酷
return links.stream().filter(d -> StringUtils.equalsIgnoreCase(d.getRel(), "Self")).collect(Collectors.toList()).get(0).getHref();
是否有任何方法可以直接从列表中代替getHref
和converting it back to list
来获取get 0th element
。>>
我需要从Rel值为String的链接列表中的href()返回值。类Links {字符串rel;字符串href; } 2类{List
是,请使用findFirst()
: