package com.lanyuanxiaoyao.service.cli.runner;

import com.lanyuanxiaoyao.service.cli.core.ServiceInfo;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * ServiceInfo 增补属性
 *
 * @author lanyuanxiaoyao
 * @date 2024-02-25
 */
public class ServiceInfoWrapper {
    private final ServiceInfo serviceInfo;

    private final String name;
    private final Map<String, Object> environments;
    private final Map<String, Object> arguments;

    public ServiceInfoWrapper(String name, ServiceInfo serviceInfo) {
        this.name = name;
        this.serviceInfo = serviceInfo;
        this.environments = SpringPropertiesEscapeHelper.escapeMap(serviceInfo.getEnvironments());
        this.arguments = SpringPropertiesEscapeHelper.escapeMap(serviceInfo.getArguments());
    }

    public Boolean getEnabled() {
        return serviceInfo.getEnabled();
    }

    public String getName() {
        return name;
    }

    public Integer getOrder() {
        return serviceInfo.getOrder();
    }

    public List<String> getGroups() {
        return serviceInfo.getGroups();
    }

    public Integer getReplicas() {
        return serviceInfo.getReplicas();
    }

    public String getSourceJar() {
        return serviceInfo.getSourceJar();
    }

    public List<String> getClasspath() {
        return serviceInfo.getClasspath();
    }

    public Map<String, Object> getEnvironments() {
        return environments;
    }

    public Map<String, Object> getArguments() {
        return arguments;
    }

    @Override
    public String toString() {
        return "ServiceInfoWrapper{" +
               "serviceInfo=" + serviceInfo +
               ", name='" + name + '\'' +
               '}';
    }
}
