package click.kamil.springstatemachineexporter.analysis.model;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.Builder;
import lombok.Data;

@Data
@Builder(toBuilder = true)
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonDeserialize(using = FlowStepDeserializer.class)
@JsonSerialize(using = FlowStepSerializer.class)
public class FlowStep {
    /** Source state identifier (package-canonical FQN or short form). */
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private final String source;
    /** Event identifier or {@code Source->Target} for anonymous transitions. */
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private final String event;
    /** Precomputed {@code #link_*} suffix for HTML/SVG highlight. */
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private final String linkKey;

    public static FlowStep ofEvent(String event) {
        return FlowStep.builder().event(event).build();
    }
}
