GrantMapperImpl.java

package org.openwms.core.uaa.impl;

import java.util.ArrayList;
import java.util.List;
import javax.annotation.processing.Generated;
import org.openwms.core.uaa.GrantMapper;
import org.openwms.core.uaa.api.GrantVO;
import org.openwms.core.uaa.api.SecurityObjectVO;
import org.springframework.stereotype.Component;

@Generated(
    value = "org.mapstruct.ap.MappingProcessor"
)
@Component
public class GrantMapperImpl implements GrantMapper {

    @Override
    public Grant convertToEO(GrantVO vo) {
        if ( vo == null ) {
            return null;
        }

        String description = null;
        String name = null;

        description = vo.getDescription();
        name = vo.getName();

        Grant grant = new Grant( name, description );

        grant.setPersistentKey( vo.getpKey() );

        return grant;
    }

    @Override
    public GrantVO convertToVO(Grant eo) {
        if ( eo == null ) {
            return null;
        }

        GrantVO grantVO = new GrantVO();

        if ( eo.hasPersistentKey() ) {
            grantVO.setpKey( eo.getPersistentKey() );
        }
        grantVO.setOl( eo.getOl() );
        grantVO.setCreateDt( eo.getCreateDt() );
        grantVO.setLastModifiedDt( eo.getLastModifiedDt() );
        grantVO.setName( eo.getName() );
        grantVO.setDescription( eo.getDescription() );

        return grantVO;
    }

    @Override
    public List<GrantVO> convertToVOs(List<Grant> eo) {
        if ( eo == null ) {
            return null;
        }

        List<GrantVO> list = new ArrayList<GrantVO>( eo.size() );
        for ( Grant grant : eo ) {
            list.add( convertToVO( grant ) );
        }

        return list;
    }

    @Override
    public SecurityObject convertToGrant(SecurityObjectVO vo) {
        if ( vo == null ) {
            return null;
        }

        if (vo instanceof GrantVO) {
            return convertToEO( (GrantVO) vo );
        }
        else {
            String name = null;

            name = vo.getName();

            SecurityObject securityObject = new SecurityObject( name );

            securityObject.setPersistentKey( vo.getpKey() );
            securityObject.setDescription( vo.getDescription() );

            return securityObject;
        }
    }
}