Hub*_*ubi 2 java list java-8 java-stream
此方法比较两个字符串。其中之一来自物体。如果字符串匹配,则ID由对象返回。
private static Long getDefaultKag(Long mandandId) {
List<MandantKagAccountEntity> mandantKagAccountEntities = new MandantKagAccountManager().findAllKags(mandandId);
for (MandantKagAccountEntity mandantKagAccountEntity : mandantKagAccountEntities) {
if (mandantKagAccountEntity.getKagText().equals("Default_kag")) {
return mandantKagAccountEntity.getMandantKagId();
}
}
return null;
}
Run Code Online (Sandbox Code Playgroud)
有什么办法可以解决流?我的方法,但我无能为力了。
private static long getDefaultKag(Long mandandId) {
return new MandantKagAccountManager().findAllKags(mandandId).stream()
.filter(m -> m.getKagText().equals("Default_Kag"))
...
...
...
}
Run Code Online (Sandbox Code Playgroud)
你有解决的办法吗?我还想知道两个变体中的哪个变体对于大量数据更有效。
更换
...
...
...
Run Code Online (Sandbox Code Playgroud)
与
.map(MandantKagAccountEntity::getMandantKagId)
.findFirst()
.orElse(null);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
119 次 |
| 最近记录: |