<commit_before>package org.radarcns.management.service.mapper;

import org.mapstruct.BeanMapping;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.radarcns.management.service.dto.ClientDetailsDTO;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.oauth2.provider.ClientDetails;
import org.springframework.security.oauth2.provider.client.BaseClientDetails;

import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

/**
 * Created by dverbeec on 7/09/2017.
 */
@Mapper(componentModel = "spring", uses = {BaseClientDetails.class})
public interface ClientDetailsMapper {

    @Mapping(target = "clientSecret", ignore = true)
    ClientDetailsDTO clientDetailsToClientDetailsDTO(ClientDetails details);
    BaseClientDetails clientDetailsDTOToClientDetails(ClientDetailsDTO detailsDTO);
    List<ClientDetailsDTO> clientDetailsToClientDetailsDTO(List<ClientDetails> detailsList);
    List<ClientDetails> clientDetailsDTOToClientDetails(List<ClientDetailsDTO> detailsDTOList);

    default Collection<GrantedAuthority> map(Set<String> authorities) {
        return authorities.stream().map(SimpleGrantedAuthority::new).collect(Collectors.toList());
    }

    default Set<String> map(Collection<GrantedAuthority> authorities) {
        return authorities.stream().map(GrantedAuthority::getAuthority).collect(Collectors.toSet());
    }

    default Map<String, String> map(Map<String, ?> additionalInformation) {
        return additionalInformation.entrySet().stream().collect(
                Collectors.toMap(e -> e.getKey(), e -> e.getValue().toString()));
    }
}
<commit_msg>Add null checks to ClientDetailsMapper<commit_after>package org.radarcns.management.service.mapper;

import org.mapstruct.BeanMapping;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.radarcns.management.service.dto.ClientDetailsDTO;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.oauth2.provider.ClientDetails;
import org.springframework.security.oauth2.provider.client.BaseClientDetails;

import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;

/**
 * Created by dverbeec on 7/09/2017.
 */
@Mapper(componentModel = "spring", uses = {BaseClientDetails.class})
public interface ClientDetailsMapper {

    @Mapping(target = "clientSecret", ignore = true)
    ClientDetailsDTO clientDetailsToClientDetailsDTO(ClientDetails details);
    BaseClientDetails clientDetailsDTOToClientDetails(ClientDetailsDTO detailsDTO);
    List<ClientDetailsDTO> clientDetailsToClientDetailsDTO(List<ClientDetails> detailsList);
    List<ClientDetails> clientDetailsDTOToClientDetails(List<ClientDetailsDTO> detailsDTOList);

    default Collection<GrantedAuthority> map(Set<String> authorities) {
        if (Objects.isNull(authorities)) {
            return Collections.emptySet();
        }
        return authorities.stream().map(SimpleGrantedAuthority::new).collect(Collectors.toList());
    }

    default Set<String> map(Collection<GrantedAuthority> authorities) {
        if (Objects.isNull(authorities)) {
            return Collections.emptySet();
        }
        return authorities.stream().map(GrantedAuthority::getAuthority).collect(Collectors.toSet());
    }

    default Map<String, String> map(Map<String, ?> additionalInformation) {
        if (Objects.isNull(additionalInformation)) {
            return Collections.emptyMap();
        }
        return additionalInformation.entrySet().stream().collect(
                Collectors.toMap(e -> e.getKey(), e -> e.getValue().toString()));
    }
}

{'fraction_non_alphanumeric': 0.10931582933602625, 'fraction_numerical': 0.0045443069931835394, 'mean_word_length': 5.200312989045384, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5713958', 'n_tokens_mistral': 1094, 'n_tokens_neox': 1084, 'n_words': 178}