package ru.kirillius.pf.sdn.pipeline;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import ru.kirillius.pf.sdn.Util.IPv4Util;
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 MergeNeighbourSubnetFilter implements PipelineFunction {

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

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

}
