EquipmentTypeCommandToDomainMapperImpl.java

package com.github.jenkaby.bikerental.equipment.application.mapper;

import com.github.jenkaby.bikerental.equipment.application.usecase.CreateEquipmentTypeUseCase;
import com.github.jenkaby.bikerental.equipment.application.usecase.UpdateEquipmentTypeUseCase;
import com.github.jenkaby.bikerental.equipment.domain.model.EquipmentType;
import javax.annotation.processing.Generated;
import org.springframework.stereotype.Component;

@Generated(
    value = "org.mapstruct.ap.MappingProcessor",
    comments = "version: 1.6.3, compiler: IncrementalProcessingEnvironment from gradle-language-java-9.4.1.jar, environment: Java 21.0.10 (Amazon.com Inc.)"
)
@Component
public class EquipmentTypeCommandToDomainMapperImpl implements EquipmentTypeCommandToDomainMapper {

    @Override
    public EquipmentType toEquipmentType(CreateEquipmentTypeUseCase.CreateEquipmentTypeCommand command) {
        if ( command == null ) {
            return null;
        }

        EquipmentType.EquipmentTypeBuilder equipmentType = EquipmentType.builder();

        equipmentType.slug( command.slug() );
        equipmentType.name( command.name() );
        equipmentType.description( command.description() );

        return equipmentType.build();
    }

    @Override
    public EquipmentType toEquipmentType(Long id, UpdateEquipmentTypeUseCase.UpdateEquipmentTypeCommand command) {
        if ( id == null && command == null ) {
            return null;
        }

        EquipmentType.EquipmentTypeBuilder equipmentType = EquipmentType.builder();

        if ( command != null ) {
            equipmentType.slug( command.slug() );
            equipmentType.name( command.name() );
            equipmentType.description( command.description() );
        }
        equipmentType.id( id );

        return equipmentType.build();
    }
}