All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.mapsmessaging.devices.sensorreadings.SensorReading Maven / Gradle / Ivy

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);
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy