package org.apache.seatunnel.transform.empty;

import com.google.auto.service.AutoService;
import org.apache.seatunnel.api.configuration.util.OptionRule;
import org.apache.seatunnel.api.table.catalog.CatalogTable;
import org.apache.seatunnel.api.table.connector.TableTransform;
import org.apache.seatunnel.api.table.factory.Factory;
import org.apache.seatunnel.api.table.factory.TableFactoryContext;
import org.apache.seatunnel.api.table.factory.TableTransformFactory;

@AutoService(Factory.class)
public class ReplaceNullTransformFactory implements TableTransformFactory {
    @Override
    public String factoryIdentifier() {
        return "ReplaceNull";
    }

    @Override
    public OptionRule optionRule() {
        return OptionRule.builder()
                .required(ReplaceNullConfig.KEY_REPLACE_FIELD_LIST).build();
    }

    @Override
    public TableTransform createTransform(TableFactoryContext context) {
        CatalogTable catalogTable = context.getCatalogTable();
        return () -> new ReplaceNullTransform(context.getOptions(), catalogTable);
    }
}
