io.github.zeroone3010.yahueapi.SensorFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of yetanotherhueapi Show documentation
Show all versions of yetanotherhueapi Show documentation
A library for controlling Philips Hue lights.
package io.github.zeroone3010.yahueapi;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.github.zeroone3010.yahueapi.domain.SensorDto;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Map;
import java.util.function.Supplier;
final class SensorFactory {
private final Hue hue;
private final ObjectMapper objectMapper;
SensorFactory(final Hue hue, final ObjectMapper objectMapper) {
this.hue = hue;
this.objectMapper = objectMapper;
}
Sensor buildSensor(final String id, final SensorDto sensor, final String bridgeUri) {
if (sensor == null) {
throw new HueApiException("Sensor " + id + " cannot be found.");
}
final URL url = buildSensorUrl(bridgeUri, id);
final SensorType type = SensorType.parseTypeString(sensor.getType());
final Supplier