I am quite new to java streams. Do I need to re-create the stream each time in this loop or is there a better way to do this? Creating the stream once and using the .noneMatch twice results in "stream already closed" exception.
for ( ItemSetNode itemSetNode : itemSetNodeList )
{
Stream<Id> allUserNodesStream = allUserNodes.stream().map( n -> n.getNodeId() );
Id nodeId = itemSetNode.getNodeId();
//if none of the user node ids match the node id, the user is missing the node
if ( allUserNodesStream.noneMatch( userNode -> userNode.compareTo( nodeId ) == 0 ) )
{
isUserMissingNode = true;
break;
}
}
Thank you !
TreeSet(asIdseems to implementComparable) or aHashSetinstead.