package easydo.technology.core;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;
import java.util.UUID;

import com.alibaba.fastjson.annotation.JSONField;

import zmo.technology.lite.core.ZeroCoreStructs;

public class DeviceSensorRecord extends ZeroCoreStructs {

    @JSONField(format = CURACAO_DATE_FORMAT)
    protected Date reportTime;

    private DeviceSensor sensor;

    public DeviceSensorRecord() {
        super();
    }

    public DeviceSensorRecord(ResultSet set) throws SQLException {
        super(set);

        if (inResultSet(set, "REPORT_TIME"))
            reportTime = new Date(set.getTimestamp("REPORT_TIME").getTime());

        if (inResultSet(set, "SENSOR_ID")) {
            sensor = new DeviceSensor();
            sensor.setId(UUID.fromString(set.getString("SENSOR_ID")));
        }
    }

    public Date getReportTime() {
        return reportTime;
    }

    public void setReportTime(Date reportTime) {
        this.reportTime = reportTime;
    }

    public DeviceSensor getSensor() {
        return sensor;
    }

    public void setSensor(DeviceSensor sensor) {
        this.sensor = sensor;
    }
}
