package cn.axzo.msg.center.inside.notices.utils;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.apache.commons.collections4.CollectionUtils;

import java.util.Collections;
import java.util.List;
import java.util.function.Function;

import static java.util.stream.Collectors.toList;

/**
 * @author yanglin
 */
public class Queries {

    public static <T, F> List<F> collect(List<T> entities, Function<T, F> idProvider) {
        if (CollectionUtils.isEmpty(entities))
            return Collections.emptyList();
        return entities.stream().map(idProvider).distinct().collect(toList());
    }

    /**
     * @param domainType help compiler
     */
    public static <T> LambdaQueryWrapper<T> query(
            @SuppressWarnings({"unused", "help compiler"}) Class<T> domainType) {
        return new LambdaQueryWrapper<>();
    }

}