package ru.kirillius.pf.sdn.flow;

import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import ru.kirillius.pf.sdn.api.flow.CallContext;
import ru.kirillius.pf.sdn.api.flow.FlowFunction;
import ru.kirillius.pf.sdn.api.properties.PropertyDescriptor;

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

@Slf4j
@RequiredArgsConstructor
public class DebugOutput implements FlowFunction {
    private final ObjectMapper objectMapper;

    @Override
    public void apply(CallContext context) {
        log.info(objectMapper.valueToTree(context.getSource()).toString());
    }

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

    @Override
    public boolean hasInputs() {
        return true;
    }

    @Override
    public boolean hasOutputs() {
        return false;
    }

}
