Prueba de controller con Lista y conversion de string
In the example we can test controller with difertent types of data incluse get a string an convert to list of string an sense inverse
@GET
@Path("/prueba/{aid}/{sid}/{anios}/{meses}/{dias}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response xample(@PathParam("aid") int aid,@PathParam("sid") String sid,
@PathParam("anios") String anios,@PathParam("meses") String meses,@PathParam("dias") String dias) {
LOGGER.info("Procesando..");
//anios 2023,2024,2025
List<Integer> aniosL = Arrays.stream(anios.split(", ")).map(Integer::parseInt).collect(Collectors.toList());
List<Integer> mesesL = Arrays.stream(meses.split(", ")).map(Integer::parseInt).collect(Collectors.toList());
List<Integer> diasL = Arrays.stream(dias.split(", ")).map(Integer::parseInt).collect(Collectors.toList());
//this is example inversed type [1,2,3,4]
final String aniosList = String.join(",", anios.stream().map(Object::toString).collect(Collectors.toList()));
cDao.xample(aid, sid, aniosL, mesesL, diasL);
return null;
}
No hay comentarios.