package com.auto.clicker.autoclicker.room;

import androidx.room.Embedded;
import androidx.room.Relation;

import com.auto.clicker.autoclicker.room.entity.EventEntity;
import com.auto.clicker.autoclicker.room.entity.TouchPoint;
import com.auto.clicker.autoclicker.room.entity.Solution;

import java.util.List;

// 这个 POJO 用于表示一个方案，以及该方案下的所有事件及其关联的坐标点
public class SolutionWithEventsAndPoints {
    @Embedded
    public Solution solution;

    @Relation(
            parentColumn = "solutionId",
            entityColumn = "solution_id",
            entity = EventEntity.class
    )
    public List<EventWithPoints> events; // 注意这里我们用 EventWithPoints

    // 内部类，用于表示一个事件以及它关联的起点和终点
    public static class EventWithPoints {
        @Embedded
        public EventEntity eventEntity;

        @Relation(
                parentColumn = "click_point_id",
                entityColumn = "pointId",
                entity = TouchPoint.class
        )
        public TouchPoint clickTouchPoint; // 单击事件的点

        @Relation(
                parentColumn = "slide_start_point_id",
                entityColumn = "pointId",
                entity = TouchPoint.class
        )
        public TouchPoint slideStartTouchPoint; // 滑动事件的起点

        @Relation(
                parentColumn = "slide_end_point_id",
                entityColumn = "pointId",
                entity = TouchPoint.class
        )
        public TouchPoint slideEndTouchPoint; // 滑动事件的终点
    }
}
