Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

109
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda