title: Spring Boot Reactive - How to convert Array response to actual DTO object?
body: <p>I am developing Spring Boot 2.7.0 and Reactive Microservices using Spring WebFlux.</p>
  <p>Below is the code</p>
  <pre><code>public void placeOrder(OrderRequest orderRequest) {
          List&lt;OrderLineItems&gt; orderLineItems = orderRequest.getOrderLineItemsDtoList()
                  .stream()
                  .map(this::mapToDto)
                  .collect(Collectors.toList());
  
          Order order = new Order();
          order.setOrderNumber(UUID.randomUUID().toString());
          order.setOrderLineItemsList(orderLineItems);
  
  
          List&lt;String&gt; skuCodes = order.getOrderLineItemsList()
                  .stream()
                  .map(orderLineItem -&gt; orderLineItem.getSkuCode())
                  .collect(Collectors.toList());
  
          // Call Inventory Service, and place order if product is in stock
          InventoryResponse[] inventoryResponsArray = webClient.get()
                  .uri(&quot;http://localhost:8092/api/inventory&quot;,
                          uriBuilder -&gt; uriBuilder.queryParam(&quot;skuCode&quot;, skuCodes).build())
                  .retrieve()
                  .bodyToMono(InventoryResponse[].class)
                  .block();
  
          boolean allProductsInStock = Arrays.stream(inventoryResponsArray)
                  .allMatch(InventoryResponse::isInStock);
  
          if(allProductsInStock){
              orderRepository.save(order);
          } else {
              throw new IllegalArgumentException(&quot;Product is not in stock, please try again later&quot;);
          }
      }
  </code></pre>
  <p>Is there any way to combine below two codes into one?</p>
  <pre><code>// Call Inventory Service, and place order if product is in stock
          InventoryResponse[] inventoryResponsArray = webClient.get()
                  .uri(&quot;http://localhost:8092/api/inventory&quot;,
                          uriBuilder -&gt; uriBuilder.queryParam(&quot;skuCode&quot;, skuCodes).build())
                  .retrieve()
                  .bodyToMono(InventoryResponse[].class)
                  .block();
  
          boolean allProductsInStock = Arrays.stream(inventoryResponsArray)
                  .allMatch(InventoryResponse::isInStock);
  </code></pre>