package com.aicheck.model;

import java.util.LinkedHashSet;
import java.util.Set;

/**
 * 索引中的 HTTP/Feign 接口：方法、URI、入参/返回类型简单名。
 */
public class ApiEndpoint {
    private final String httpMethod;
    private final String uri;
    private final String sourceFile;
    private final Set<String> paramTypes;
    private final Set<String> returnTypes;

    public ApiEndpoint(String httpMethod, String uri, String sourceFile,
                       Set<String> paramTypes, Set<String> returnTypes) {
        this.httpMethod = httpMethod;
        this.uri = uri;
        this.sourceFile = sourceFile;
        this.paramTypes = paramTypes == null ? Set.of() : new LinkedHashSet<>(paramTypes);
        this.returnTypes = returnTypes == null ? Set.of() : new LinkedHashSet<>(returnTypes);
    }

    public String getHttpMethod() {
        return httpMethod;
    }

    public String getUri() {
        return uri;
    }

    /** 定义该接口的 Java 源文件相对路径 */
    public String getSourceFile() {
        return sourceFile;
    }

    /** 入参涉及的类型简单名集合 */
    public Set<String> getParamTypes() {
        return paramTypes;
    }

    /** 返回值涉及的类型简单名集合（已剥离泛型包装） */
    public Set<String> getReturnTypes() {
        return returnTypes;
    }

    /** 去重用键：METHOD + URI */
    public String endpointKey() {
        return httpMethod + " " + uri;
    }

    /** 通知展示行：GET  /api/foo */
    public String displayLine() {
        return httpMethod + "  " + uri;
    }
}
