package cn.axzo.workflow.core.service.converter;

import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public interface EntityConverter<V, E> {

    V toVo(E entity);

    default List<V> toVos(List<E> entities) {
        if (CollectionUtils.isEmpty(entities)) {
            return Collections.emptyList();
        }
        List<V> vos = new ArrayList<>();
        entities.forEach(i -> vos.add(toVo(i)));
        return vos;
    }
}
