Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

108
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda