package cz.senslog.analytics.domain;

import java.time.OffsetDateTime;

public class Observation implements TimeSeriesDatasource {

    private final Sensor sensor;
    private final RawObservation rawObservation;

    public static Observation of(Sensor sensor, RawObservation rawObservation) {
        return new Observation(sensor, rawObservation);
    }

    private Observation(Sensor sensor, RawObservation rawObservation) {
        this.sensor = sensor;
        this.rawObservation = rawObservation;
    }

    @Override
    public OffsetDateTime timestamp() {
        return rawObservation.timestamp();
    }

    @Override
    public long datasourceId() {
        return sensor.id();
    }

    public Sensor sensor() {
        return sensor;
    }

    public double value() {
        return rawObservation.value();
    }
}
