Ignore order in list

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Ignore order in list

hlopez
I have an ArrayList with two objects.

I'm expecting that the RESTService will give me the same back and trying to validate:
[{"id":4,"firstName":"Carla","lastName":"Bentley","email":"tryingmy@somema1l.us","account":734709,"address":"515 Bonaparte Drv"},{"id":3,"firstName":"Lindsey","lastName":"Craft","email":"isheadphones@ma1lbox.net","account":618284,"address":"869 Southard Blvd"}]

Except that my RESTService is sometimes giving them back in wrong order. (was expecting the first to be id=3 and the second to be id=4).

     List<Person> list = new ArrayList<>();
     list.add(person3);
     list.add(person4);
     ....
     builder.endpoint(httpClient)
     ....
     .payload(list, objectMapper)
Is there a way to ignore the order?

Thanks,
Humphrey