package com.oguerreiro.resilient.service.mapper.security;

import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

import com.oguerreiro.resilient.security.resillient.SecurityGroup;
import com.oguerreiro.resilient.security.resillient.SecurityGroupPermission;
import com.oguerreiro.resilient.service.dto.security.SecurityGroupDTO;
import com.oguerreiro.resilient.service.dto.security.SecurityGroupPermissionDTO;
import com.oguerreiro.resilient.service.mapper.ResilientEntityMapper;

/**
 * Mapper for the entity {@link SecurityGroup} and its DTO {@link SecurityGroupDTO}.
 */
@Mapper(componentModel = "spring")
public interface SecurityGroupMapper extends ResilientEntityMapper<SecurityGroupDTO, SecurityGroup> {
  // Maps only SecurityGroup, without any other relation
  @Mapping(target = "securityGroupPermissions", ignore = true)
  SecurityGroupDTO toDto(SecurityGroup s);

  @Mapping(target = "securityGroup", ignore = true)
  SecurityGroupPermissionDTO toDto(SecurityGroupPermission s);

  /*
  @Named("securityGroupPermissionPropertyName")
  @BeanMapping(ignoreByDefault = true)
  @Mapping(target = "id", source = "id")
  @Mapping(target = "version", source = "version")
  SecurityGroupPermissionDTO toDtoSecurityGroupPermissionPropertyName(SecurityGroupPermission securityGroupPermission);
  
  @Named("securityGroupPermissionNameSet")
  default List<SecurityGroupPermissionDTO> toDtoSecurityGroupPermissionPropertyNameSet(
      List<SecurityGroupPermission> securityGroupPermission) {
    return securityGroupPermission.stream().map(this::toDtoSecurityGroupPermissionPropertyName).collect(
        Collectors.toList());
  }
  */
}
