OrderRestMapperImpl.java
package com.dmasone.identity.orders.interfaces.rest;
import com.dmasone.identity.orders.application.OrderResponse;
import com.dmasone.identity.orders.application.PlaceOrderCommand;
import com.dmasone.identity.orders.domain.OrderStatus;
import java.time.Instant;
import java.util.UUID;
import javax.annotation.processing.Generated;
import org.springframework.stereotype.Component;
@Generated(
value = "org.mapstruct.ap.MappingProcessor"
)
@Component
public class OrderRestMapperImpl implements OrderRestMapper {
@Override
public PlaceOrderCommand toCommand(PlaceOrderRequest request, String idempotencyKey) {
if ( request == null && idempotencyKey == null ) {
return null;
}
Long productId = null;
int quantity = 0;
if ( request != null ) {
productId = request.productId();
if ( request.quantity() != null ) {
quantity = request.quantity();
}
}
String idempotencyKey1 = null;
idempotencyKey1 = idempotencyKey;
PlaceOrderCommand placeOrderCommand = new PlaceOrderCommand( productId, quantity, idempotencyKey1 );
return placeOrderCommand;
}
@Override
public OrderDto toDto(OrderResponse response) {
if ( response == null ) {
return null;
}
UUID id = null;
Long productId = null;
int quantity = 0;
OrderStatus status = null;
Instant createdAt = null;
id = response.id();
productId = response.productId();
quantity = response.quantity();
status = response.status();
createdAt = response.createdAt();
OrderDto orderDto = new OrderDto( id, productId, quantity, status, createdAt );
return orderDto;
}
}