com.eurodyn.qlack.fuse.aaa.mappers.UserMapperImpl Maven / Gradle / Ivy
package com.eurodyn.qlack.fuse.aaa.mappers;
import com.eurodyn.qlack.fuse.aaa.dto.UserAttributeDTO;
import com.eurodyn.qlack.fuse.aaa.dto.UserDTO;
import com.eurodyn.qlack.fuse.aaa.model.User;
import com.eurodyn.qlack.fuse.aaa.model.UserAttribute;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.annotation.Generated;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Generated(
value = "org.mapstruct.ap.MappingProcessor",
date = "2019-05-03T08:55:23+0000",
comments = "version: 1.3.0.Final, compiler: javac, environment: Java 1.8.0_161 (Oracle Corporation)"
)
@Component
public class UserMapperImpl implements UserMapper {
@Autowired
private UserAttributeMapper userAttributeMapper;
@Override
public UserDTO mapToDTO(User entity) {
if ( entity == null ) {
return null;
}
UserDTO userDTO = new UserDTO();
userDTO.setId( entity.getId() );
userDTO.setUsername( entity.getUsername() );
userDTO.setPassword( entity.getPassword() );
userDTO.setStatus( entity.getStatus() );
userDTO.setSuperadmin( entity.isSuperadmin() );
userDTO.setExternal( entity.isExternal() );
userDTO.setUserAttributes( userAttributeListToUserAttributeDTOSet( entity.getUserAttributes() ) );
return userDTO;
}
@Override
public List mapToDTO(List entity) {
if ( entity == null ) {
return null;
}
List list = new ArrayList( entity.size() );
for ( User user : entity ) {
list.add( mapToDTO( user ) );
}
return list;
}
@Override
public User mapToEntity(UserDTO dto) {
if ( dto == null ) {
return null;
}
User user = new User();
user.setId( dto.getId() );
user.setPassword( dto.getPassword() );
user.setStatus( dto.getStatus() );
user.setUsername( dto.getUsername() );
user.setSuperadmin( dto.isSuperadmin() );
user.setExternal( dto.isExternal() );
user.setUserAttributes( userAttributeDTOSetToUserAttributeList( dto.getUserAttributes() ) );
return user;
}
@Override
public List mapToEntity(List dto) {
if ( dto == null ) {
return null;
}
List list = new ArrayList( dto.size() );
for ( UserDTO userDTO : dto ) {
list.add( mapToEntity( userDTO ) );
}
return list;
}
@Override
public void mapToExistingEntity(UserDTO dto, User user) {
if ( dto == null ) {
return;
}
user.setId( dto.getId() );
user.setStatus( dto.getStatus() );
user.setUsername( dto.getUsername() );
user.setSuperadmin( dto.isSuperadmin() );
user.setExternal( dto.isExternal() );
}
protected Set userAttributeListToUserAttributeDTOSet(List list) {
if ( list == null ) {
return null;
}
Set set = new HashSet( Math.max( (int) ( list.size() / .75f ) + 1, 16 ) );
for ( UserAttribute userAttribute : list ) {
set.add( userAttributeMapper.mapToDTO( userAttribute ) );
}
return set;
}
protected List userAttributeDTOSetToUserAttributeList(Set set) {
if ( set == null ) {
return null;
}
List list = new ArrayList( set.size() );
for ( UserAttributeDTO userAttributeDTO : set ) {
list.add( userAttributeMapper.mapToEntity( userAttributeDTO ) );
}
return list;
}
}