Skip to content
Advertisement

Java find Object which not containing in List of object

I wondering is there any way to filter object array with another object array. Its is to hard to explain but ill try my best

this is my first entity

JavaScript

this is second entity

JavaScript

i have two list of this each entities Like this

JavaScript

And I need to get MDynamicFieldTypes list which not containing in dynamicFields->type List and add fake object to which not containing in the dynamicFields List

as the example

First list like this

JavaScript

Second one like this

JavaScript

i need get as the result following List

JavaScript

Advertisement

Answer

Here is a two step solution

First create a set of all existing types in the dynamicFields list

JavaScript

Then use that set to filter out any non-existing type in the dynamicFieldTypes list

JavaScript
Advertisement