Skip to content

Commit

Permalink
#14 Rename constant supportsThingTypes to SUPPORTED_THING_TYPES in Bo…
Browse files Browse the repository at this point in the history
…schSHCHandlerFactory

Signed-off-by: Christian Oeing <[email protected]>
Signed-off-by: Gerd Zanker <[email protected]>
  • Loading branch information
coeing authored and GerdZanker committed Jan 7, 2021
1 parent cc66008 commit 0140d99
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public ThingTypeHandlerMapping(ThingTypeUID thingTypeUID, Function<Thing, BaseTh
}
}

private static final Collection<ThingTypeHandlerMapping> supportedThingTypes = Arrays.asList(
private static final Collection<ThingTypeHandlerMapping> SUPPORTED_THING_TYPES = Arrays.asList(
new ThingTypeHandlerMapping(THING_TYPE_SHC, thing -> new BoschSHCBridgeHandler((Bridge) thing)),
new ThingTypeHandlerMapping(THING_TYPE_INWALL_SWITCH, BoschInWallSwitchHandler::new),
new ThingTypeHandlerMapping(THING_TYPE_TWINGUARD, BoschTwinguardHandler::new),
Expand All @@ -77,15 +77,15 @@ public ThingTypeHandlerMapping(ThingTypeUID thingTypeUID, Function<Thing, BaseTh

@Override
public boolean supportsThingType(ThingTypeUID thingTypeUID) {
return supportedThingTypes.stream().anyMatch(mapping -> mapping.thingTypeUID.equals(thingTypeUID));
return SUPPORTED_THING_TYPES.stream().anyMatch(mapping -> mapping.thingTypeUID.equals(thingTypeUID));
}

@Override
protected @Nullable ThingHandler createHandler(Thing thing) {
ThingTypeUID thingTypeUID = thing.getThingTypeUID();

// Search for mapping for thing type and return handler for it if found. Otherwise return null.
return supportedThingTypes.stream().filter(mapping -> mapping.thingTypeUID.equals(thingTypeUID)).findFirst()
return SUPPORTED_THING_TYPES.stream().filter(mapping -> mapping.thingTypeUID.equals(thingTypeUID)).findFirst()
.<@Nullable BaseThingHandler> map(mapping -> mapping.handlerSupplier.apply(thing)).orElse(null);
}
}

0 comments on commit 0140d99

Please sign in to comment.