package enea.lecservice.widgets;


import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import enea.lecservice.widgets.chart.models.ChartWidget;
import enea.lecservice.widgets.image.models.ImageWidget;
import enea.lecservice.widgets.table.models.TableWidget;
import enea.lecservice.widgets.text.models.TextWidget;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.SuperBuilder;

@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@Getter @Setter
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXISTING_PROPERTY, property = "type", visible = true)
@JsonSubTypes({
        @JsonSubTypes.Type(value = TextWidget.class, name = "TEXT"),
        @JsonSubTypes.Type(value = TableWidget.class, name = "TABLE"),
        @JsonSubTypes.Type(value = ChartWidget.class, name = "CHART"),
        @JsonSubTypes.Type(value = ImageWidget.class, name = "IMAGE")
})
public abstract class Widget {
    protected WidgetType type;

    @JsonFormat(shape = JsonFormat.Shape.STRING)
    public enum WidgetType {
        TEXT,
        TABLE,
        CHART,
        IMAGE,
        LAYOUT
    }
}
