I have two lists of objects dbAssets and assetVOS.
I want common elements (and difference) by some property (getSecName() in my case) using streams.
I've tried the following:
dbAssets.stream().map(SomeClass::getSecName)
.filter(dbAssetName -> assetVOS.stream()
.map(SomeClass::getSecName)
.anyMatch(assetVOSName -> dbAssetName.equals(assetVOSName)))
.collect(Collectors.toList());
But I'm getting the following error:
Incompatible types. Required
List<SomeClass>but 'collect' was inferred to R: no instance(s) of type variable(s) exist so thatStringconforms toSomeClassinference variable T has incompatible bounds: equality constraints:SomeClasslower boundsString