package <%=packageName%>.web.rest.mapper;

import <%=packageName%>.domain.Authority;
import <%=packageName%>.domain.User;
import <%=packageName%>.web.rest.dto.UserDTO;
import org.mapstruct.Mapper;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * Mapper for the entity User and its DTO UserDTO.
 */
@Mapper(componentModel = "spring", uses = {})
public interface UserMapper {

    UserDTO userToUserDTO(User user);

    List<UserDTO> usersToUserDTOs(List<User> users);

    User userDTOToUser(UserDTO userDTO);

    List<User> userDTOsToUsers(List<UserDTO> userDTOs);

    default User userFromId(Long id) {
        if (id == null) {
            return null;
        }
        User user = new User();
        user.setId(id);
        return user;
    }

    default Set<String> stringsFromAuthorities(Set<Authority> authorities) {
        Set<String> auths = new HashSet<>();
        for(Authority auth : authorities){
            auths.add(auth.getName());
        }
        return auths;
    }

    default Set<Authority> authoritiesFromStrings(Set<String> strings) {
        Set<Authority> auths = new HashSet<>();
        for(String auth : strings){
            Authority a = new Authority();
            a.setName(auth);
            auths.add(a);
        }
        return auths;
    }
}

@@ -32,24 +32,88 @@
 st.mapper;%0A%0A
+%3C%25 if (databaseType == 'sql' %7C%7C databaseType == 'mongodb') %7B %25%3E%0A
 import %3C%25=pa
@@ -141,16 +141,23 @@
 thority;
+%3C%25 %7D %25%3E
 %0Aimport 
@@ -694,12 +694,108 @@
 mId(
-Long
+%3C%25 if (databaseType == 'mongodb' %7C%7C databaseType == 'cassandra') %7B %25%3EString%3C%25 %7D else %7B %25%3ELong%3C%25 %7D %25%3E
  id)
@@ -933,33 +933,96 @@
 urn user;%0A    %7D%0A
+%3C%25 if (databaseType == 'sql' %7C%7C databaseType == 'mongodb') %7B %25%3E
 %0A
-
     default Set%3C
@@ -1535,16 +1535,23 @@
  auths;%0A
-
     %7D
+%3C%25 %7D %25%3E
 %0A%7D%0A

use Authority class only when using sql or mongoldb, use string id for mongodb and Cassandra