mirror of
https://github.com/danieldemus/openhab-core.git
synced 2026-07-29 12:34:22 +02:00
Added nullness annotations to ThingHandlerHelper (#1993)
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
This commit is contained in:
+2
@@ -12,6 +12,7 @@
|
||||
*/
|
||||
package org.openhab.core.thing.util;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.openhab.core.thing.Thing;
|
||||
import org.openhab.core.thing.ThingStatus;
|
||||
import org.openhab.core.thing.binding.ThingHandler;
|
||||
@@ -22,6 +23,7 @@ import org.openhab.core.thing.binding.ThingHandler;
|
||||
* @author Markus Rathgeb - Initial contribution
|
||||
* @author Simon Kaufmann - added UNKNOWN
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public class ThingHandlerHelper {
|
||||
|
||||
private ThingHandlerHelper() {
|
||||
|
||||
+6
-6
@@ -18,7 +18,6 @@ import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.mockito.MockitoAnnotations.openMocks;
|
||||
import static org.openhab.core.thing.util.ThingHandlerHelper.isHandlerInitialized;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -58,6 +57,7 @@ import org.openhab.core.thing.link.ItemChannelLinkRegistry;
|
||||
import org.openhab.core.thing.link.ManagedItemChannelLinkProvider;
|
||||
import org.openhab.core.thing.type.ChannelKind;
|
||||
import org.openhab.core.thing.type.ChannelTypeUID;
|
||||
import org.openhab.core.thing.util.ThingHandlerHelper;
|
||||
import org.openhab.core.types.Command;
|
||||
import org.openhab.core.util.BundleResolver;
|
||||
import org.osgi.framework.Bundle;
|
||||
@@ -96,7 +96,7 @@ public class ChannelLinkNotifierOSGiTest extends JavaOSGiTest {
|
||||
|
||||
private final @Nullable ThingStatus thingStatus;
|
||||
|
||||
private Map<ChannelUID, List<Boolean>> channelLinkEvents = new HashMap<>();
|
||||
private final Map<ChannelUID, List<Boolean>> channelLinkEvents = new HashMap<>();
|
||||
|
||||
public TestHandler(Thing thing, @Nullable ThingStatus thingStatus) {
|
||||
super(thing);
|
||||
@@ -118,12 +118,12 @@ public class ChannelLinkNotifierOSGiTest extends JavaOSGiTest {
|
||||
|
||||
@Override
|
||||
public void channelLinked(ChannelUID channelUID) {
|
||||
channelLinkEvents.get(channelUID).add(Boolean.TRUE);
|
||||
channelLinkEvents.getOrDefault(channelUID, List.of()).add(Boolean.TRUE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelUnlinked(ChannelUID channelUID) {
|
||||
channelLinkEvents.get(channelUID).add(Boolean.FALSE);
|
||||
channelLinkEvents.getOrDefault(channelUID, List.of()).add(Boolean.FALSE);
|
||||
}
|
||||
|
||||
public List<Boolean> getChannelLinkEvents(ChannelUID channelUID) {
|
||||
@@ -208,13 +208,13 @@ public class ChannelLinkNotifierOSGiTest extends JavaOSGiTest {
|
||||
|
||||
private Thing addInitializedThing() {
|
||||
Thing thing = addThing(ThingStatus.ONLINE);
|
||||
assertThat(isHandlerInitialized(thing.getHandler()), is(true));
|
||||
assertThat(ThingHandlerHelper.isHandlerInitialized(getHandler(thing)), is(true));
|
||||
return thing;
|
||||
}
|
||||
|
||||
private Thing addUninitializedThing() {
|
||||
Thing thing = addThing(null);
|
||||
assertThat(isHandlerInitialized(thing.getHandler()), is(false));
|
||||
assertThat(ThingHandlerHelper.isHandlerInitialized(getHandler(thing)), is(false));
|
||||
return thing;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user