22
22
import java .util .List ;
23
23
import java .util .Map ;
24
24
import java .util .Objects ;
25
- import java .util .Optional ;
26
25
27
26
import org .eclipse .jdt .annotation .NonNullByDefault ;
28
27
import org .eclipse .jdt .annotation .Nullable ;
@@ -662,22 +661,22 @@ public State getRotaryStepsLastUpdatedState(ZoneId zoneId) {
662
661
}
663
662
664
663
/**
665
- * Check if the scene resource contains a 'status.active' element. If such an element is present, returns a Boolean
666
- * Optional whose value depends on the value of that element, or an empty Optional if it is not.
664
+ * Check if the scene resource contains a 'status.active' element. Returns a Boolean if such an element is present,
665
+ * whose value depends on the value of that element, or null if it is not.
667
666
*
668
- * @return true, false, or empty .
667
+ * @return true, false, or null .
669
668
*/
670
- public Optional < Boolean > getSceneActive () {
669
+ public @ Nullable Boolean getSceneActive () {
671
670
if (ResourceType .SCENE == getType ()) {
672
671
JsonElement status = this .status ;
673
672
if (Objects .nonNull (status ) && status .isJsonObject ()) {
674
673
JsonElement active = ((JsonObject ) status ).get ("active" );
675
674
if (Objects .nonNull (active ) && active .isJsonPrimitive ()) {
676
- return Optional . of ( !"inactive" .equalsIgnoreCase (active .getAsString () ));
675
+ return !"inactive" .equalsIgnoreCase (active .getAsString ());
677
676
}
678
677
}
679
678
}
680
- return Optional . empty () ;
679
+ return null ;
681
680
}
682
681
683
682
/**
@@ -688,42 +687,42 @@ public Optional<Boolean> getSceneActive() {
688
687
}
689
688
690
689
/**
691
- * If the getSceneActive() optional result is empty return 'UnDefType.NULL'. Otherwise if the optional result is
692
- * present and 'true' (i.e. the scene is active) return the scene name. Or finally (the optional result is present
693
- * and 'false') return 'UnDefType.UNDEF'.
690
+ * Depending on the returned value from getSceneActive() this method returns 'UnDefType.NULL' for 'null',
691
+ * 'UnDefType.UNDEF' for 'false' or when 'true' (i.e. the scene is active) return the scene name.
694
692
*
695
- * @return either 'UnDefType.NULL', a StringType containing the (active) scene name, or 'UnDefType.UNDEF '.
693
+ * @return either a StringType containing the (active) scene name, 'UnDefType.UNDEF' or 'UnDefType.NULL '.
696
694
*/
697
695
public State getSceneState () {
698
- return getSceneActive ().map (a -> a ? new StringType (getName ()) : UnDefType .UNDEF ).orElse (UnDefType .NULL );
696
+ Boolean sceneActive = getSceneActive ();
697
+ return sceneActive != null ? sceneActive ? new StringType (getName ()) : UnDefType .UNDEF : UnDefType .NULL ;
699
698
}
700
699
701
700
/**
702
701
* Check if the smart scene resource contains a 'state' element. If such an element is present, returns a Boolean
703
- * Optional whose value depends on the value of that element, or an empty Optional if it is not. Note that in some
704
- * resource types the 'state' element is not a String primitive.
702
+ * whose value depends on the value of that element, or null if it is not.
705
703
*
706
- * @return true, false, or empty .
704
+ * @return true, false, or null .
707
705
*/
708
- public Optional < Boolean > getSmartSceneActive () {
706
+ public @ Nullable Boolean getSmartSceneActive () {
709
707
if (ResourceType .SMART_SCENE == getType () && (state instanceof JsonPrimitive statePrimitive )) {
710
708
String state = statePrimitive .getAsString ();
711
709
if (Objects .nonNull (state )) {
712
- return Optional . of ( SmartSceneState .ACTIVE == SmartSceneState .of (state ) );
710
+ return SmartSceneState .ACTIVE == SmartSceneState .of (state );
713
711
}
714
712
}
715
- return Optional . empty () ;
713
+ return null ;
716
714
}
717
715
718
716
/**
719
- * If the getSmartSceneActive() optional result is empty return 'UnDefType.NULL'. Otherwise if the optional result
720
- * is present and 'true' (i.e. the scene is active) return the smart scene name. Or finally (the optional result is
721
- * present and 'false') return 'UnDefType.UNDEF'.
717
+ * Depending on the returned value from getSmartSceneActive() this method returns 'UnDefType.NULL' for 'null',
718
+ * 'UnDefType.UNDEF' for 'false' or when 'true' (i.e. the scene is active) return the scene name.
722
719
*
723
- * @return either 'UnDefType.NULL', a StringType containing the (active) scene name, or 'UnDefType.UNDEF '.
720
+ * @return either a StringType containing the (active) scene name, 'UnDefType.UNDEF' or 'UnDefType.NULL '.
724
721
*/
725
722
public State getSmartSceneState () {
726
- return getSmartSceneActive ().map (a -> a ? new StringType (getName ()) : UnDefType .UNDEF ).orElse (UnDefType .NULL );
723
+ Boolean smartSceneActive = getSmartSceneActive ();
724
+ return smartSceneActive != null ? smartSceneActive ? new StringType (getName ()) : UnDefType .UNDEF
725
+ : UnDefType .NULL ;
727
726
}
728
727
729
728
public List <ResourceReference > getServiceReferences () {
0 commit comments