package org.takiguchi.cerberus.cerberusapp.persistence.mapper;

import org.springframework.stereotype.Component;
import org.takiguchi.cerberus.cerberusapp.model.Application;
import org.takiguchi.cerberus.cerberusapp.persistence.model.ApplicationEntity;

import static org.takiguchi.cerberus.cerberusapp.model.Application.anApplication;

@Component
public class ApplicationEntityMapper {

    public Application mapToDomain(ApplicationEntity entity) {
        return anApplication()
                .withId(entity.getId())
                .withName(entity.getName())
                .withServiceName(entity.getServiceName())
                .withServiceType(entity.getServiceType())
                .build();
    }

    public ApplicationEntity mapToEntity(Application application) {
        return new ApplicationEntity(
                application.getId(),
                application.getName(),
                application.getServiceName(),
                application.getServiceType()
        );
    }
}
