All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.eurodyn.qlack.fuse.aaa.mapper.UserGroupMapperImpl Maven / Gradle / Ivy

The newest version!
package com.eurodyn.qlack.fuse.aaa.mapper;

import com.eurodyn.qlack.fuse.aaa.dto.UserGroupDTO;
import com.eurodyn.qlack.fuse.aaa.model.UserGroup;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import javax.annotation.processing.Generated;
import org.springframework.stereotype.Component;

@Generated(
    value = "org.mapstruct.ap.MappingProcessor",
    date = "2024-09-20T10:45:53+0000",
    comments = "version: 1.5.5.Final, compiler: javac, environment: Java 17.0.2 (Private Build)"
)
@Component
public class UserGroupMapperImpl implements UserGroupMapper {

    @Override
    public UserGroupDTO mapToDTO(UserGroup userGroup, boolean lazyRelatives) {
        if ( userGroup == null ) {
            return null;
        }

        UserGroupDTO userGroupDTO = new UserGroupDTO();

        userGroupDTO.setParentId( userGroupParentId( userGroup ) );
        userGroupDTO.setChildren( mapChildren( userGroup.getChildren(), lazyRelatives ) );
        userGroupDTO.setId( userGroup.getId() );
        userGroupDTO.setName( userGroup.getName() );
        userGroupDTO.setObjectId( userGroup.getObjectId() );
        userGroupDTO.setDescription( userGroup.getDescription() );

        return userGroupDTO;
    }

    @Override
    public List mapToDTO(List userGroups, boolean lazyRelatives) {
        if ( userGroups == null ) {
            return null;
        }

        List list = new ArrayList( userGroups.size() );
        for ( UserGroup userGroup : userGroups ) {
            list.add( mapToDTO( userGroup, lazyRelatives ) );
        }

        return list;
    }

    @Override
    public UserGroup mapToEntity(UserGroupDTO userGroupDTO) {
        if ( userGroupDTO == null ) {
            return null;
        }

        UserGroup userGroup = new UserGroup();

        userGroup.setParent( mapParent( userGroupDTO.getParentId() ) );
        userGroup.setId( userGroupDTO.getId() );
        userGroup.setDescription( userGroupDTO.getDescription() );
        userGroup.setName( userGroupDTO.getName() );
        userGroup.setObjectId( userGroupDTO.getObjectId() );
        userGroup.setChildren( userGroupDTOSetToUserGroupList( userGroupDTO.getChildren() ) );

        return userGroup;
    }

    @Override
    public List mapToEntity(List userGroupsDTO) {
        if ( userGroupsDTO == null ) {
            return null;
        }

        List list = new ArrayList( userGroupsDTO.size() );
        for ( UserGroupDTO userGroupDTO : userGroupsDTO ) {
            list.add( mapToEntity( userGroupDTO ) );
        }

        return list;
    }

    @Override
    public void mapToExistingEntity(UserGroupDTO userGroupDTO, UserGroup userGroup) {
        if ( userGroupDTO == null ) {
            return;
        }

        userGroup.setId( userGroupDTO.getId() );
        userGroup.setDescription( userGroupDTO.getDescription() );
        userGroup.setName( userGroupDTO.getName() );
        userGroup.setObjectId( userGroupDTO.getObjectId() );
        if ( userGroup.getChildren() != null ) {
            List list = userGroupDTOSetToUserGroupList( userGroupDTO.getChildren() );
            if ( list != null ) {
                userGroup.getChildren().clear();
                userGroup.getChildren().addAll( list );
            }
            else {
                userGroup.setChildren( null );
            }
        }
        else {
            List list = userGroupDTOSetToUserGroupList( userGroupDTO.getChildren() );
            if ( list != null ) {
                userGroup.setChildren( list );
            }
        }
    }

    private String userGroupParentId(UserGroup userGroup) {
        if ( userGroup == null ) {
            return null;
        }
        UserGroup parent = userGroup.getParent();
        if ( parent == null ) {
            return null;
        }
        String id = parent.getId();
        if ( id == null ) {
            return null;
        }
        return id;
    }

    protected List userGroupDTOSetToUserGroupList(Set set) {
        if ( set == null ) {
            return null;
        }

        List list = new ArrayList( set.size() );
        for ( UserGroupDTO userGroupDTO : set ) {
            list.add( mapToEntity( userGroupDTO ) );
        }

        return list;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy