com.eurodyn.qlack.fuse.aaa.mappers.SessionMapperImpl Maven / Gradle / Ivy
package com.eurodyn.qlack.fuse.aaa.mappers;
import com.eurodyn.qlack.fuse.aaa.dto.SessionAttributeDTO;
import com.eurodyn.qlack.fuse.aaa.dto.SessionDTO;
import com.eurodyn.qlack.fuse.aaa.model.Session;
import com.eurodyn.qlack.fuse.aaa.model.SessionAttribute;
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 SessionMapperImpl implements SessionMapper {
@Autowired
private SessionAttributeMapper sessionAttributeMapper;
@Override
public SessionDTO mapToDTO(Session entity) {
if ( entity == null ) {
return null;
}
SessionDTO sessionDTO = new SessionDTO();
sessionDTO.setId( entity.getId() );
sessionDTO.setCreatedOn( entity.getCreatedOn() );
sessionDTO.setTerminatedOn( entity.getTerminatedOn() );
sessionDTO.setApplicationSessionId( entity.getApplicationSessionId() );
sessionDTO.setSessionAttributes( sessionAttributeListToSessionAttributeDTOSet( entity.getSessionAttributes() ) );
return sessionDTO;
}
@Override
public List mapToDTO(List entity) {
if ( entity == null ) {
return null;
}
List list = new ArrayList( entity.size() );
for ( Session session : entity ) {
list.add( mapToDTO( session ) );
}
return list;
}
@Override
public Session mapToEntity(SessionDTO dto) {
if ( dto == null ) {
return null;
}
Session session = new Session();
session.setId( dto.getId() );
session.setApplicationSessionId( dto.getApplicationSessionId() );
session.setCreatedOn( dto.getCreatedOn() );
session.setTerminatedOn( dto.getTerminatedOn() );
session.setSessionAttributes( sessionAttributeDTOSetToSessionAttributeList( dto.getSessionAttributes() ) );
return session;
}
@Override
public void mapToExistingEntity(SessionDTO dto, Session entity) {
if ( dto == null ) {
return;
}
entity.setId( dto.getId() );
entity.setApplicationSessionId( dto.getApplicationSessionId() );
entity.setCreatedOn( dto.getCreatedOn() );
entity.setTerminatedOn( dto.getTerminatedOn() );
if ( entity.getSessionAttributes() != null ) {
List list = sessionAttributeDTOSetToSessionAttributeList( dto.getSessionAttributes() );
if ( list != null ) {
entity.getSessionAttributes().clear();
entity.getSessionAttributes().addAll( list );
}
else {
entity.setSessionAttributes( null );
}
}
else {
List list = sessionAttributeDTOSetToSessionAttributeList( dto.getSessionAttributes() );
if ( list != null ) {
entity.setSessionAttributes( list );
}
}
}
@Override
public List mapToEntity(List dto) {
if ( dto == null ) {
return null;
}
List list = new ArrayList( dto.size() );
for ( SessionDTO sessionDTO : dto ) {
list.add( mapToEntity( sessionDTO ) );
}
return list;
}
protected Set sessionAttributeListToSessionAttributeDTOSet(List list) {
if ( list == null ) {
return null;
}
Set set = new HashSet( Math.max( (int) ( list.size() / .75f ) + 1, 16 ) );
for ( SessionAttribute sessionAttribute : list ) {
set.add( sessionAttributeMapper.mapToDTO( sessionAttribute ) );
}
return set;
}
protected List sessionAttributeDTOSetToSessionAttributeList(Set set) {
if ( set == null ) {
return null;
}
List list = new ArrayList( set.size() );
for ( SessionAttributeDTO sessionAttributeDTO : set ) {
list.add( sessionAttributeMapper.mapToEntity( sessionAttributeDTO ) );
}
return list;
}
}