package com.jy.framework.mybatis.join;

import com.baomidou.mybatisplus.core.toolkit.StringPool;
import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

@RequiredArgsConstructor(access = AccessLevel.PROTECTED)
public class QueryColumns extends AbstractSql {

    List<QueryColumn> queryColumnList = new ArrayList<>();

    protected void add(QueryColumn queryColumn) {
        queryColumnList.add(queryColumn);
    }

    @Override
    protected String format() {
        return queryColumnList.stream().map(QueryColumn::format).collect(Collectors.joining(StringPool.COMMA));
    }

}
