BlankMessagingDataMapperImpl.java

package com.blanksystem.blank.service.message.mapper;

import com.blanksystem.blank.service.domain.dto.message.BlankModel;
import com.blanksystem.blank.service.domain.entity.Blank;
import com.blanksystem.blank.service.domain.event.BlankEvent;
import com.blanksystem.blank.service.domain.valueobject.BlankId;
import com.blanksystem.blank.service.message.model.avro.BlankAvroModel;
import java.util.UUID;
import javax.annotation.processing.Generated;
import org.springframework.stereotype.Component;

@Generated(
    value = "org.mapstruct.ap.MappingProcessor",
    date = "2024-11-04T20:44:05+0000",
    comments = "version: 1.6.2, compiler: javac, environment: Java 21.0.5 (Azul Systems, Inc.)"
)
@Component
public class BlankMessagingDataMapperImpl implements BlankMessagingDataMapper {

    @Override
    public BlankAvroModel customerCreatedEventToCustomerRequestAvroModel(BlankEvent blankEvent) {
        if ( blankEvent == null ) {
            return null;
        }

        BlankAvroModel.Builder blankAvroModel = BlankAvroModel.newBuilder();

        UUID value = blankEventBlankIdValue( blankEvent );
        if ( value != null ) {
            blankAvroModel.setId( value.toString() );
        }

        return blankAvroModel.build();
    }

    @Override
    public BlankModel blankAvroModelToBlankModel(BlankAvroModel blankAvroModel) {
        if ( blankAvroModel == null ) {
            return null;
        }

        BlankModel.BlankModelBuilder blankModel = BlankModel.builder();

        blankModel.id( blankAvroModel.getId() );

        return blankModel.build();
    }

    private UUID blankEventBlankIdValue(BlankEvent blankEvent) {
        Blank blank = blankEvent.getBlank();
        if ( blank == null ) {
            return null;
        }
        BlankId id = blank.getId();
        if ( id == null ) {
            return null;
        }
        return id.getValue();
    }
}