package com.jeeplus.sys.service.mapstruct;

import com.jeeplus.core.dto.DragNode;
import com.jeeplus.sys.domain.Menu;
import com.jeeplus.sys.domain.vo.MenuVO;
import com.jeeplus.sys.domain.vo.MetaVO;
import com.jeeplus.sys.service.dto.DataRuleDTO;
import com.jeeplus.sys.service.dto.MenuDTO;
import com.jeeplus.sys.service.dto.UserDTO;
import org.springframework.stereotype.Component;

import javax.annotation.Generated;
import java.util.ArrayList;
import java.util.List;

@Generated(
        value = "org.mapstruct.ap.MappingProcessor",
        date = "2022-08-18T16:46:54+0800",
        comments = "version: 1.4.1.Final, compiler: javac, environment: Java 1.8.0_221 (Oracle Corporation)"
)
@Component
public class MenuWrapperImpl implements MenuWrapper {

    @Override
    public Menu toEntity(MenuDTO arg0) {
        if ( arg0 == null ) {
            return null;
        }

        Menu menu = new Menu ( );

        menu.setParentId ( arg0ParentId ( arg0 ) );
        menu.setCreateById ( arg0CreateById ( arg0 ) );
        menu.setUpdateById ( arg0UpdateById ( arg0 ) );
        menu.setId ( arg0.getId ( ) );
        menu.setCreateTime ( arg0.getCreateTime ( ) );
        menu.setUpdateTime ( arg0.getUpdateTime ( ) );
        menu.setDelFlag ( arg0.getDelFlag ( ) );
        menu.setParentIds ( arg0.getParentIds ( ) );
        menu.setName ( arg0.getName ( ) );
        menu.setSort ( arg0.getSort ( ) );
        menu.setChildren ( toEntity ( arg0.getChildren ( ) ) );
        menu.setCode ( arg0.getCode ( ) );
        menu.setHref ( arg0.getHref ( ) );
        menu.setTarget ( arg0.getTarget ( ) );
        menu.setIcon ( arg0.getIcon ( ) );
        menu.setIsShow ( arg0.getIsShow ( ) );
        menu.setType ( arg0.getType ( ) );
        menu.setPermission ( arg0.getPermission ( ) );
        menu.setAffix ( arg0.getAffix ( ) );
        menu.setRemarks ( arg0.getRemarks ( ) );

        return menu;
    }

    @Override
    public MenuDTO toDTO(Menu arg0) {
        if ( arg0 == null ) {
            return null;
        }

        MenuDTO menuDTO = new MenuDTO ( );

        menuDTO.setParent ( menuToMenuDTO ( arg0 ) );
        menuDTO.setCreateBy ( menuToUserDTO ( arg0 ) );
        menuDTO.setUpdateBy ( menuToUserDTO1 ( arg0 ) );
        menuDTO.setId ( arg0.getId ( ) );
        menuDTO.setCreateTime ( arg0.getCreateTime ( ) );
        menuDTO.setUpdateTime ( arg0.getUpdateTime ( ) );
        menuDTO.setDelFlag ( arg0.getDelFlag ( ) );
        menuDTO.setChildren ( toDTO ( arg0.getChildren ( ) ) );
        menuDTO.setParentIds ( arg0.getParentIds ( ) );
        menuDTO.setName ( arg0.getName ( ) );
        menuDTO.setSort ( arg0.getSort ( ) );
        menuDTO.setCode ( arg0.getCode ( ) );
        menuDTO.setHref ( arg0.getHref ( ) );
        menuDTO.setTarget ( arg0.getTarget ( ) );
        menuDTO.setIcon ( arg0.getIcon ( ) );
        menuDTO.setIsShow ( arg0.getIsShow ( ) );
        menuDTO.setType ( arg0.getType ( ) );
        menuDTO.setPermission ( arg0.getPermission ( ) );
        menuDTO.setAffix ( arg0.getAffix ( ) );
        menuDTO.setRemarks ( arg0.getRemarks ( ) );

        return menuDTO;
    }

    @Override
    public Menu copyEntity(Menu arg0) {
        if ( arg0 == null ) {
            return null;
        }

        Menu menu = new Menu ( );

        menu.setId ( arg0.getId ( ) );
        menu.setCreateTime ( arg0.getCreateTime ( ) );
        menu.setCreateById ( arg0.getCreateById ( ) );
        menu.setUpdateTime ( arg0.getUpdateTime ( ) );
        menu.setUpdateById ( arg0.getUpdateById ( ) );
        menu.setDelFlag ( arg0.getDelFlag ( ) );
        menu.setTenantId ( arg0.getTenantId ( ) );
        menu.setParentId ( arg0.getParentId ( ) );
        menu.setParentIds ( arg0.getParentIds ( ) );
        menu.setName ( arg0.getName ( ) );
        menu.setSort ( arg0.getSort ( ) );
        List <Menu> list = arg0.getChildren ( );
        if ( list != null ) {
            menu.setChildren ( new ArrayList <Menu> ( list ) );
        }
        menu.setCode ( arg0.getCode ( ) );
        menu.setHref ( arg0.getHref ( ) );
        menu.setTarget ( arg0.getTarget ( ) );
        menu.setIcon ( arg0.getIcon ( ) );
        menu.setIsShow ( arg0.getIsShow ( ) );
        menu.setType ( arg0.getType ( ) );
        menu.setPermission ( arg0.getPermission ( ) );
        menu.setAffix ( arg0.getAffix ( ) );
        menu.setRemarks ( arg0.getRemarks ( ) );

        return menu;
    }

    @Override
    public MenuDTO copyDTO(MenuDTO arg0) {
        if ( arg0 == null ) {
            return null;
        }

        MenuDTO menuDTO = new MenuDTO ( );

        menuDTO.setId ( arg0.getId ( ) );
        menuDTO.setCreateTime ( arg0.getCreateTime ( ) );
        menuDTO.setCreateBy ( arg0.getCreateBy ( ) );
        menuDTO.setUpdateTime ( arg0.getUpdateTime ( ) );
        menuDTO.setUpdateBy ( arg0.getUpdateBy ( ) );
        menuDTO.setDelFlag ( arg0.getDelFlag ( ) );
        menuDTO.setTenantDTO ( arg0.getTenantDTO ( ) );
        menuDTO.setParent ( copyDTO ( arg0.getParent ( ) ) );
        List <MenuDTO> list = arg0.getChildren ( );
        if ( list != null ) {
            menuDTO.setChildren ( new ArrayList <MenuDTO> ( list ) );
        }
        menuDTO.setParentIds ( arg0.getParentIds ( ) );
        menuDTO.setName ( arg0.getName ( ) );
        menuDTO.setSort ( arg0.getSort ( ) );
        menuDTO.setCode ( arg0.getCode ( ) );
        menuDTO.setHref ( arg0.getHref ( ) );
        menuDTO.setTarget ( arg0.getTarget ( ) );
        menuDTO.setIcon ( arg0.getIcon ( ) );
        menuDTO.setIsShow ( arg0.getIsShow ( ) );
        menuDTO.setType ( arg0.getType ( ) );
        menuDTO.setPermission ( arg0.getPermission ( ) );
        List <DataRuleDTO> list1 = arg0.getDataRuleDTOList ( );
        if ( list1 != null ) {
            menuDTO.setDataRuleDTOList ( new ArrayList <DataRuleDTO> ( list1 ) );
        }
        menuDTO.setUserId ( arg0.getUserId ( ) );
        menuDTO.setAffix ( arg0.getAffix ( ) );
        menuDTO.setRemarks ( arg0.getRemarks ( ) );

        return menuDTO;
    }

    @Override
    public List <Menu> toEntity(List <MenuDTO> arg0) {
        if ( arg0 == null ) {
            return null;
        }

        List <Menu> list = new ArrayList <Menu> ( arg0.size ( ) );
        for (MenuDTO menuDTO : arg0) {
            list.add ( toEntity ( menuDTO ) );
        }

        return list;
    }

    @Override
    public List <MenuDTO> toDTO(List <Menu> arg0) {
        if ( arg0 == null ) {
            return null;
        }

        List <MenuDTO> list = new ArrayList <MenuDTO> ( arg0.size ( ) );
        for (Menu menu : arg0) {
            list.add ( toDTO ( menu ) );
        }

        return list;
    }

    @Override
    public DragNode <Menu> toEntity(DragNode <MenuDTO> arg0) {
        if ( arg0 == null ) {
            return null;
        }

        DragNode <Menu> dragNode = new DragNode <Menu> ( );

        dragNode.setDraggingNode ( toEntity ( arg0.getDraggingNode ( ) ) );
        dragNode.setDropNode ( toEntity ( arg0.getDropNode ( ) ) );
        dragNode.setDropType ( arg0.getDropType ( ) );

        return dragNode;
    }

    @Override
    public MenuVO toVO(MenuDTO menuDTO) {
        if ( menuDTO == null ) {
            return null;
        }

        MenuVO menuVO = new MenuVO ( );

        menuVO.setMeta ( menuDTOToMetaVO ( menuDTO ) );
        menuVO.setPath ( menuDTO.getHref ( ) );
        menuVO.setName ( menuDTO.getName ( ) );
        menuVO.setChildren ( menuDTOListToMenuVOList ( menuDTO.getChildren ( ) ) );

        return menuVO;
    }

    private String arg0ParentId(MenuDTO menuDTO) {
        if ( menuDTO == null ) {
            return null;
        }
        MenuDTO parent = menuDTO.getParent ( );
        if ( parent == null ) {
            return null;
        }
        String id = parent.getId ( );
        if ( id == null ) {
            return null;
        }
        return id;
    }

    private String arg0CreateById(MenuDTO menuDTO) {
        if ( menuDTO == null ) {
            return null;
        }
        UserDTO createBy = menuDTO.getCreateBy ( );
        if ( createBy == null ) {
            return null;
        }
        String id = createBy.getId ( );
        if ( id == null ) {
            return null;
        }
        return id;
    }

    private String arg0UpdateById(MenuDTO menuDTO) {
        if ( menuDTO == null ) {
            return null;
        }
        UserDTO updateBy = menuDTO.getUpdateBy ( );
        if ( updateBy == null ) {
            return null;
        }
        String id = updateBy.getId ( );
        if ( id == null ) {
            return null;
        }
        return id;
    }

    protected MenuDTO menuToMenuDTO(Menu menu) {
        if ( menu == null ) {
            return null;
        }

        MenuDTO menuDTO = new MenuDTO ( );

        menuDTO.setId ( menu.getParentId ( ) );

        return menuDTO;
    }

    protected UserDTO menuToUserDTO(Menu menu) {
        if ( menu == null ) {
            return null;
        }

        UserDTO userDTO = new UserDTO ( );

        userDTO.setId ( menu.getCreateById ( ) );

        return userDTO;
    }

    protected UserDTO menuToUserDTO1(Menu menu) {
        if ( menu == null ) {
            return null;
        }

        UserDTO userDTO = new UserDTO ( );

        userDTO.setId ( menu.getUpdateById ( ) );

        return userDTO;
    }

    protected MetaVO menuDTOToMetaVO(MenuDTO menuDTO) {
        if ( menuDTO == null ) {
            return null;
        }

        MetaVO metaVO = new MetaVO ( );

        metaVO.setId ( menuDTO.getId ( ) );
        metaVO.setTarget ( menuDTO.getTarget ( ) );
        metaVO.setIcon ( menuDTO.getIcon ( ) );
        metaVO.setType ( menuDTO.getType ( ) );
        metaVO.setIsShow ( menuDTO.getIsShow ( ) );
        metaVO.setAffix ( menuDTO.getAffix ( ) );
        metaVO.setCode ( menuDTO.getCode ( ) );
        metaVO.setTitle ( menuDTO.getName ( ) );

        return metaVO;
    }

    protected List <MenuVO> menuDTOListToMenuVOList(List <MenuDTO> list) {
        if ( list == null ) {
            return null;
        }

        List <MenuVO> list1 = new ArrayList <MenuVO> ( list.size ( ) );
        for (MenuDTO menuDTO : list) {
            list1.add ( toVO ( menuDTO ) );
        }

        return list1;
    }
}
