package ru.kirillius.pf.sdn.pipeline;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import ru.kirillius.pf.sdn.api.Networking.NetworkScope;
import ru.kirillius.pf.sdn.api.pipeline.PipelineFunction;
import ru.kirillius.pf.sdn.api.properties.PropertyDescriptor;

import java.util.Collections;
import java.util.Map;

@Slf4j
@RequiredArgsConstructor
public class DuplicatesFilter implements PipelineFunction {

    @Override
    public NetworkScope apply(NetworkScope source, Map<String, String> properties) {
        var output = new NetworkScope();
        output.setSubnets(source.getSubnets().stream().distinct().toList());
        output.setDomains(source.getDomains().stream().distinct().toList());
        output.setASN(source.getASN().stream().distinct().toList());
        output.setAutoResolvedDomains(source.getAutoResolvedDomains().stream().distinct().toList());
        return output;
    }

    @Override
    public Map<String, PropertyDescriptor> getProperties() {
        return Collections.emptyMap();
    }

}
