io.mapsmessaging.devices.sensorreadings.SensorReading Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of deviceLibrary Show documentation
Show all versions of deviceLibrary Show documentation
Provides a plugable Device integration and access
The newest version!
package io.mapsmessaging.devices.sensorreadings;
import lombok.Getter;
import java.io.IOException;
@Getter
public class SensorReading {
private final String name;
@Getter
private final String unit;
private final ReadingSupplier supplier;
protected SensorReading(String name, String unit, ReadingSupplier valueSupplier) {
this.name = name;
this.unit = unit;
this.supplier = valueSupplier;
}
public ComputationResult getValue() {
try {
return ComputationResult.success(supplier.get());
} catch (IOException ioException) {
return ComputationResult.failure(ioException);
}
}
}