BlankDataMapperImpl.java

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

import com.blanksystem.blank.service.domain.dto.create.CreateBlankCommand;
import com.blanksystem.blank.service.domain.dto.create.CreateBlankResponse;
import com.blanksystem.blank.service.domain.entity.Blank;
import com.blanksystem.blank.service.domain.valueobject.BlankId;
import java.util.UUID;
import javax.annotation.processing.Generated;
import org.springframework.stereotype.Component;

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

    @Override
    public Blank createBlankCommandToBlank(CreateBlankCommand createBlankCommand) {
        if ( createBlankCommand == null ) {
            return null;
        }

        BlankId blankId = null;

        Blank blank = new Blank( blankId );

        blank.setId( map( createBlankCommand.id() ) );

        return blank;
    }

    @Override
    public CreateBlankResponse blankToCreateBlankResponse(Blank blank, String message) {
        if ( blank == null && message == null ) {
            return null;
        }

        CreateBlankResponse.CreateBlankResponseBuilder createBlankResponse = CreateBlankResponse.builder();

        if ( blank != null ) {
            createBlankResponse.id( blankIdValue( blank ) );
        }
        createBlankResponse.message( message );

        return createBlankResponse.build();
    }

    private UUID blankIdValue(Blank blank) {
        BlankId id = blank.getId();
        if ( id == null ) {
            return null;
        }
        return id.getValue();
    }
}