All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jonpereiradev.jfile.reader.rule.configurator.RefRuleConfiguratorImpl Maven / Gradle / Ivy

package com.jonpereiradev.jfile.reader.rule.configurator;

import com.jonpereiradev.jfile.reader.rule.RuleConfiguratorContext;
import com.jonpereiradev.jfile.reader.rule.column.ColumnRule;
import com.jonpereiradev.jfile.reader.rule.column.DomainRefRule;
import com.jonpereiradev.jfile.reader.rule.column.FilledRefRule;

import java.util.Arrays;
import java.util.List;

final class RefRuleConfiguratorImpl implements RefRuleConfigurator {

    private final int refPosition;
    private final int position;
    private final RuleConfiguratorContext context;
    private final T currentConfigurator;

    RefRuleConfiguratorImpl(int refPosition, int position, RuleConfiguratorContext context, T currentConfigurator) {
        this.refPosition = refPosition;
        this.position = position;
        this.context = context;
        this.currentConfigurator = currentConfigurator;
    }

    @Override
    public T filled() {
        context.getRuleConfiguration().getColumnRules().add(new FilledRefRule(refPosition, position));
        return currentConfigurator;
    }

    @Override
    @SuppressWarnings("unchecked")
    public T filled(Object... values) {
        List rules = context.getRuleConfiguration().getColumnRules();
        rules.add(new DomainRefRule(refPosition, position, Arrays.asList(values)));
        return currentConfigurator;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy