AdoptionMapperImpl.java

package org.petify.shelter.mapper;

import java.time.LocalDateTime;
import javax.annotation.processing.Generated;
import org.petify.shelter.dto.AdoptionRequest;
import org.petify.shelter.dto.AdoptionResponse;
import org.petify.shelter.enums.AdoptionStatus;
import org.petify.shelter.model.Adoption;
import org.petify.shelter.model.Pet;
import org.springframework.stereotype.Component;

@Generated(
    value = "org.mapstruct.ap.MappingProcessor",
    date = "2025-06-26T07:25:37+0000",
    comments = "version: 1.6.3, compiler: javac, environment: Java 21.0.7 (Oracle Corporation)"
)
@Component
public class AdoptionMapperImpl implements AdoptionMapper {

    @Override
    public Adoption toEntity(AdoptionRequest adoptionRequest) {
        if ( adoptionRequest == null ) {
            return null;
        }

        Adoption adoption = new Adoption();

        adoption.setMotivationText( adoptionRequest.motivationText() );
        adoption.setFullName( adoptionRequest.fullName() );
        adoption.setPhoneNumber( adoptionRequest.phoneNumber() );
        adoption.setAddress( adoptionRequest.address() );
        adoption.setHousingType( adoptionRequest.housingType() );
        adoption.setHasYard( adoptionRequest.hasYard() );
        adoption.setHasOtherPets( adoptionRequest.hasOtherPets() );
        adoption.setDescription( adoptionRequest.description() );

        return adoption;
    }

    @Override
    public AdoptionResponse toDto(Adoption adoption) {
        if ( adoption == null ) {
            return null;
        }

        Long petId = null;
        Long id = null;
        String username = null;
        AdoptionStatus adoptionStatus = null;
        String motivationText = null;
        String fullName = null;
        String phoneNumber = null;
        String address = null;
        String housingType = null;
        boolean hasYard = false;
        boolean hasOtherPets = false;
        String description = null;
        LocalDateTime applicationDate = null;

        petId = adoptionPetId( adoption );
        id = adoption.getId();
        username = adoption.getUsername();
        adoptionStatus = adoption.getAdoptionStatus();
        motivationText = adoption.getMotivationText();
        fullName = adoption.getFullName();
        phoneNumber = adoption.getPhoneNumber();
        address = adoption.getAddress();
        housingType = adoption.getHousingType();
        hasYard = adoption.isHasYard();
        hasOtherPets = adoption.isHasOtherPets();
        description = adoption.getDescription();
        applicationDate = adoption.getApplicationDate();

        boolean isHouseOwner = false;

        AdoptionResponse adoptionResponse = new AdoptionResponse( id, username, petId, adoptionStatus, motivationText, fullName, phoneNumber, address, housingType, isHouseOwner, hasYard, hasOtherPets, description, applicationDate );

        return adoptionResponse;
    }

    private Long adoptionPetId(Adoption adoption) {
        Pet pet = adoption.getPet();
        if ( pet == null ) {
            return null;
        }
        return pet.getId();
    }
}