Compare two lists of different objects by certain two fields

I have two lists of different objects

class objectA {
String aId;
String aTitle;
String aUrl;
class objectB {
String bId;
String bTitle;
String bUrl;

List<ObjectA> aObjectList;
List<ObjectB> bObjectList;

I need to verify that these two lists have equal values for Id and Title fields. The way I see is to create Map<String, String> from two lists and then compare them.

List<Map<String, String>> aObjectMapList =
List<Map<String, String>> bObjectMapList =

But maybe assertj has an appropriate approach to solve my issue?

I would be grateful for any solution to my issue via stream or assertj or somehow else.


It could make sense to merge id / title into a single String, remap the input lists into List<String> and then use AssertJ hasSameElements to compare the new lists:

               .map(a -> String.join(":", a.aId, a.aTitle))
               .map(b -> String.join(":", b.bId, b.bTitle))