package com.elderbyte.vidada.domain.auth.users;

import java.util.stream.Collectors;

public class VidadaUserDtoBuilder {

    public static VidadaUserDto build(VidadaUser user){
        VidadaUserDto dto = new VidadaUserDto();
        dto.username = user.getUsername();
        dto.firstName = user.getFirstName();
        dto.lastName = user.getLastName();
        dto.enabled = user.isEnabled();

        dto.authorities = user.getAuthorities().stream()
            .map(a -> a.getAuthority())
            .collect(Collectors.toSet());

        return dto;
    }

}
