So im checking for null but still getting an error… trying in two different ways here:
Null type mismatch (type annotations): required ‘org.openhab.binding.sonoff.internal.api.@NonNull Switch’ but this expression has type ‘org.openhab.binding.sonoff.internal.api.@Nullable Switch’
List<Switch> switches = new ArrayList<>();
if (device.getParams().getSwitches().get(0).getSwitch() != null) {
switches.add(gson.fromJson("{switch:" + device.getParams().getSwitches().get(0).getSwitch() + ",outlet: 0}",
Switch.class));
} else {
switches.add(gson.fromJson("{switch:" + "off" + ",outlet: 0}", Switch.class));
}
switches.add(gson.fromJson("{switch:" + device.getParams().getSwitches().get(1).getSwitch() != null
? device.getParams().getSwitches().get(1).getSwitch()
: "off" + ",outlet: 1}", Switch.class));