[OmniLink] Use for each loop in getChildThing() (#9963)
* Use for each loop in getChildThing() Signed-off-by: Ethan Dye <mrtops03@gmail.com> * Further refine getChildThing() using stream map Signed-off-by: Ethan Dye <mrtops03@gmail.com> * Fix spotless errors Signed-off-by: Ethan Dye <mrtops03@gmail.com>
This commit is contained in:
parent
a49b3487fa
commit
e8ba8ec47b
@ -185,4 +185,6 @@ public class OmnilinkBindingConstants {
|
|||||||
THING_TYPE_BUTTON, THING_TYPE_UNIT_UPB, THING_TYPE_THERMOSTAT, THING_TYPE_CONSOLE, THING_TYPE_AUDIO_ZONE,
|
THING_TYPE_BUTTON, THING_TYPE_UNIT_UPB, THING_TYPE_THERMOSTAT, THING_TYPE_CONSOLE, THING_TYPE_AUDIO_ZONE,
|
||||||
THING_TYPE_AUDIO_SOURCE, THING_TYPE_TEMP_SENSOR, THING_TYPE_HUMIDITY_SENSOR, THING_TYPE_LOCK,
|
THING_TYPE_AUDIO_SOURCE, THING_TYPE_TEMP_SENSOR, THING_TYPE_HUMIDITY_SENSOR, THING_TYPE_LOCK,
|
||||||
THING_TYPE_OUTPUT, THING_TYPE_UNIT, THING_TYPE_DIMMABLE);
|
THING_TYPE_OUTPUT, THING_TYPE_UNIT, THING_TYPE_DIMMABLE);
|
||||||
|
public static final Set<ThingTypeUID> SUPPORTED_UNIT_TYPES_UIDS = Set.of(THING_TYPE_UNIT_UPB, THING_TYPE_ROOM,
|
||||||
|
THING_TYPE_FLAG, THING_TYPE_OUTPUT, THING_TYPE_DIMMABLE, THING_TYPE_UNIT);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -568,24 +568,8 @@ public class OmnilinkBridgeHandler extends BaseBridgeHandler implements Notifica
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Optional<Thing> getUnitThing(int unitId) {
|
private Optional<Thing> getUnitThing(int unitId) {
|
||||||
Optional<Thing> theThing = getChildThing(THING_TYPE_UNIT_UPB, unitId);
|
return SUPPORTED_UNIT_TYPES_UIDS.stream().map(uid -> getChildThing(uid, unitId)).flatMap(Optional::stream)
|
||||||
if (!(theThing.isPresent())) {
|
.findFirst();
|
||||||
theThing = getChildThing(THING_TYPE_ROOM, unitId);
|
|
||||||
}
|
|
||||||
if (!(theThing.isPresent())) {
|
|
||||||
theThing = getChildThing(THING_TYPE_FLAG, unitId);
|
|
||||||
}
|
|
||||||
if (!(theThing.isPresent())) {
|
|
||||||
theThing = getChildThing(THING_TYPE_OUTPUT, unitId);
|
|
||||||
}
|
|
||||||
if (!(theThing.isPresent())) {
|
|
||||||
theThing = getChildThing(THING_TYPE_DIMMABLE, unitId);
|
|
||||||
}
|
|
||||||
if (!(theThing.isPresent())) {
|
|
||||||
theThing = getChildThing(THING_TYPE_UNIT, unitId);
|
|
||||||
}
|
|
||||||
|
|
||||||
return theThing;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<AudioPlayer> getAudioPlayer() {
|
public Optional<AudioPlayer> getAudioPlayer() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user