GroupNode Class:
@Data
public class GroupNode {
private String groupName;
private List<PolicyNode> policies;
private String eventId;
}
PolicyNode Class:
@Data
public class PolicyNode {
private String policyName;
private String eventTime;
private String eventId;
}
Here i want is if eventId of groupNode matches with the eventId of policyNode then i want to set the policyNode details in groupNode.
the code i've tried.
List<GroupNode> groupWithPolicy = groupWithoutPolicy.stream()
.filter(gwp->groupPolicyNodeList.stream().anyMatch(gwop->gwop.getEventId().equals(gwp.getEventId())))
.collect(Collectors.toList());
I know that i'm not setting any property here but I'm not getting any idea how to set those properties to a group node:/
this is the sample response i want:
"groups": [
{
"groupName": "My group",
"policies": [
{
"policyName": "Inno-Test-Cust-Man-Policy",
"eventId": "67e3426e-fd42-483f-9d90-8f7d15646f6a",
},
{
"policyName": "Inno-Test-Cust-Man-Policy",
"eventId": "67e3426e-fd42-483f-9d90-8f7d15646f6a",
}
],
"eventId": "2d72752d-8f28-4549-9c0c-986ac98873cf"
}
]
}
I removed lot of data from above output here the eventId's are not matching. so i've all groups list without policies attached to it. and all policies list. now based on eventId i want to add policies to the group.
question from:
https://stackoverflow.com/questions/65868432/if-any-match-found-in-the-stream-set-data-to-innerobject-of-the-first-object-in 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…