package com.boman.report.constant;

import com.google.common.collect.Sets;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Component;

import java.util.Collections;
import java.util.HashSet;
import java.util.Set;

/**
 * @author shiqian
 * @date 2021年08月27日 16:24
 **/
@Configurable
@RefreshScope
@Component
public class IgnoreTable {

    @Value("${report.tableNames}")
    private String ignoreTableNames;



    public String getIgnoreTableNames() {
        return ignoreTableNames;
    }

    public void setIgnoreTableNames(String ignoreTableNames) {
        this.ignoreTableNames = ignoreTableNames;
    }

    public Set<String> getSet() {
        if (null != ignoreTableNames && ignoreTableNames.length() != 0) {
            String[] split = ignoreTableNames.split(",");
            HashSet<String> tableNameSet = Sets.newHashSet();
            Collections.addAll(tableNameSet, split);
            return tableNameSet;
        }

        return null;
    }

}
