package edu.prlab.tyler.iotgateway.cloud.pojo.device;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import java.util.List;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Entity
public class Device {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private long id;

    private String udn;

    private String name;

    @Enumerated(value = EnumType.STRING)
    private Type type;

    @OneToOne(cascade = CascadeType.ALL)
    @JoinColumn(name = "manufacturer_id")
    private Manufacturer manufacturer;

    @OneToOne(cascade = CascadeType.ALL)
    @JoinColumn(name = "model_id")
    private Model model;

    private String UPC;

    private String location;

    @OneToMany(targetEntity = Icon.class, cascade = CascadeType.ALL)
    @JoinColumn(name = "icon_id")
    private List<Icon> icons;

    @Enumerated(value = EnumType.STRING)
    private Status status;

    public enum Type {
        Sensor, Actuator, Mixed, Other
    }

    public enum Status {
        Connected, Connecting, Disconnected, Disconnecting
    }

}
