package com.lingyue.graph.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 节点引用
 * 用于数据源绑定不同类型的节点
 * 
 * @author lingyue
 * @since 2026-01-21
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Schema(description = "节点引用")
public class NodeRef {
    
    public static final String TYPE_GRAPH_NODE = "graph_node";
    public static final String TYPE_DOCUMENT_ELEMENT = "document_element";
    
    @Schema(description = "节点类型", example = "graph_node/document_element")
    private String type;
    
    @Schema(description = "节点ID")
    private String id;
    
    /**
     * 创建图节点引用
     */
    public static NodeRef graphNode(String id) {
        return new NodeRef(TYPE_GRAPH_NODE, id);
    }
    
    /**
     * 创建文档元素引用
     */
    public static NodeRef documentElement(String id) {
        return new NodeRef(TYPE_DOCUMENT_ELEMENT, id);
    }
    
    public boolean isGraphNode() {
        return TYPE_GRAPH_NODE.equals(type);
    }
    
    public boolean isDocumentElement() {
        return TYPE_DOCUMENT_ELEMENT.equals(type);
    }
}
