Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

107
Views
Modify values in list of objects dependant on same key across all objects in list

I have a list of objects as follows.

List<Map<String, CustomObject>> xList = getData();

xList's structure as follows.

[
    {
        ask: {
            description: {
                pricing: "200",
                // other key / values
            }
        },
        // other key / values
    },
    {
        description: {
            pricing: "500",
            // other key / values
        }
        // other key / values
    },
    more objects
]

I am looking to change the value for the pricing key.

This key is meant to be used for sorting via another service and looking to hide actual value.

Thus for example if the pricing value for Object1 is 200 and Object2 is 500, I wish to modify the object / or create a copy as follows where the pricing value is ordered from the lowest:

[
    {
        ask: {
            description: {
                pricing: "1", // order 1 cos 200 is lower than 500
                // other key / values
            }
        },
        // other key / values
    },
    {
        ask: {
            description: {
                pricing: "2", // order 2 cos 500 is higher than 200
                // other key / values
            }
        },
        // other key / values
    },
    more objects
]

But for me to know the order value correctly, I am gonna need to know
all the pricing values first before modifying anything.

Unable to see how I could know all the pricing values and modify the values via a stream. Could I get some advice please.

Was attempting something like the following but as said I can't be doing this without knowing all the pricing values first.

List<Map<String, CustomObject>> xList = getData();

xList.stream().map(AllData::getAsk)
        .map(map -> map.get("description"))
        .map(stringObjectMap -> stringObjectMap.get("pricing"))

or

for (CustomObject data : xList) {
    Map<String, Object> map = data.getAsk().get("description");
    int pricing = Integer.parseInt((String) map.get("pricing"));
}
over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!