Skip to content

Commit 0af7440

Browse files
authored
Added nullness annotations to ThingHandlerHelper (#1993)
Signed-off-by: Christoph Weitkamp <[email protected]>
1 parent df20138 commit 0af7440

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/util/ThingHandlerHelper.java

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
*/
1313
package org.openhab.core.thing.util;
1414

15+
import org.eclipse.jdt.annotation.NonNullByDefault;
1516
import org.openhab.core.thing.Thing;
1617
import org.openhab.core.thing.ThingStatus;
1718
import org.openhab.core.thing.binding.ThingHandler;
@@ -22,6 +23,7 @@
2223
* @author Markus Rathgeb - Initial contribution
2324
* @author Simon Kaufmann - added UNKNOWN
2425
*/
26+
@NonNullByDefault
2527
public class ThingHandlerHelper {
2628

2729
private ThingHandlerHelper() {

itests/org.openhab.core.thing.tests/src/main/java/org/openhab/core/thing/internal/ChannelLinkNotifierOSGiTest.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import static org.mockito.ArgumentMatchers.eq;
1919
import static org.mockito.Mockito.when;
2020
import static org.mockito.MockitoAnnotations.openMocks;
21-
import static org.openhab.core.thing.util.ThingHandlerHelper.isHandlerInitialized;
2221

2322
import java.util.ArrayList;
2423
import java.util.HashMap;
@@ -58,6 +57,7 @@
5857
import org.openhab.core.thing.link.ManagedItemChannelLinkProvider;
5958
import org.openhab.core.thing.type.ChannelKind;
6059
import org.openhab.core.thing.type.ChannelTypeUID;
60+
import org.openhab.core.thing.util.ThingHandlerHelper;
6161
import org.openhab.core.types.Command;
6262
import org.openhab.core.util.BundleResolver;
6363
import org.osgi.framework.Bundle;
@@ -96,7 +96,7 @@ class TestHandler extends BaseThingHandler {
9696

9797
private final @Nullable ThingStatus thingStatus;
9898

99-
private Map<ChannelUID, List<Boolean>> channelLinkEvents = new HashMap<>();
99+
private final Map<ChannelUID, List<Boolean>> channelLinkEvents = new HashMap<>();
100100

101101
public TestHandler(Thing thing, @Nullable ThingStatus thingStatus) {
102102
super(thing);
@@ -118,12 +118,12 @@ public void initialize() {
118118

119119
@Override
120120
public void channelLinked(ChannelUID channelUID) {
121-
channelLinkEvents.get(channelUID).add(Boolean.TRUE);
121+
channelLinkEvents.getOrDefault(channelUID, List.of()).add(Boolean.TRUE);
122122
}
123123

124124
@Override
125125
public void channelUnlinked(ChannelUID channelUID) {
126-
channelLinkEvents.get(channelUID).add(Boolean.FALSE);
126+
channelLinkEvents.getOrDefault(channelUID, List.of()).add(Boolean.FALSE);
127127
}
128128

129129
public List<Boolean> getChannelLinkEvents(ChannelUID channelUID) {
@@ -208,13 +208,13 @@ private TestHandler getHandler(Thing thing) {
208208

209209
private Thing addInitializedThing() {
210210
Thing thing = addThing(ThingStatus.ONLINE);
211-
assertThat(isHandlerInitialized(thing.getHandler()), is(true));
211+
assertThat(ThingHandlerHelper.isHandlerInitialized(getHandler(thing)), is(true));
212212
return thing;
213213
}
214214

215215
private Thing addUninitializedThing() {
216216
Thing thing = addThing(null);
217-
assertThat(isHandlerInitialized(thing.getHandler()), is(false));
217+
assertThat(ThingHandlerHelper.isHandlerInitialized(getHandler(thing)), is(false));
218218
return thing;
219219
}
220220

0 commit comments

Comments
 (0)