
package dev.sonpx.loyalty.mcp.filter;

import java.util.Arrays;
import java.util.List;
import lombok.Builder;
import lombok.Data;
import org.springframework.util.CollectionUtils;

/**
 * Created by SonPhung on Monday, 09-Oct-2023
 */
@Data
@Builder
public class OlsFilterSpec {

    private Filter<?> filter;
    private String column;
    private String param;
    private List<String> columns;

    public boolean searchFilter() {
        return !CollectionUtils.isEmpty(columns);
    }

    public static OlsFilterSpec of(Filter<?> filter, String column, String param) {
        return OlsFilterSpec.builder()
                .filter(filter)
                .column(column)
                .param(param)
                .build();
    }

    public static OlsFilterSpec of(Filter<?> filter, String param, String... columns) {
        return OlsFilterSpec.builder()
                .filter(filter)
                .columns(Arrays.stream(columns).toList())
                .param(param)
                .build();
    }
}
