8686import org .openhab .core .model .sitemap .sitemap .Buttongrid ;
8787import org .openhab .core .model .sitemap .sitemap .Chart ;
8888import org .openhab .core .model .sitemap .sitemap .ColorArray ;
89+ import org .openhab .core .model .sitemap .sitemap .ColorArrayList ;
8990import org .openhab .core .model .sitemap .sitemap .Colortemperaturepicker ;
9091import org .openhab .core .model .sitemap .sitemap .Condition ;
9192import org .openhab .core .model .sitemap .sitemap .Frame ;
9293import org .openhab .core .model .sitemap .sitemap .IconRule ;
94+ import org .openhab .core .model .sitemap .sitemap .IconRuleList ;
9395import org .openhab .core .model .sitemap .sitemap .Image ;
9496import org .openhab .core .model .sitemap .sitemap .Input ;
9597import org .openhab .core .model .sitemap .sitemap .LinkableWidget ;
102104import org .openhab .core .model .sitemap .sitemap .Switch ;
103105import org .openhab .core .model .sitemap .sitemap .Video ;
104106import org .openhab .core .model .sitemap .sitemap .VisibilityRule ;
107+ import org .openhab .core .model .sitemap .sitemap .VisibilityRuleList ;
105108import org .openhab .core .model .sitemap .sitemap .Webview ;
106109import org .openhab .core .model .sitemap .sitemap .Widget ;
107110import org .openhab .core .types .State ;
@@ -615,7 +618,8 @@ private PageDTO createPageBean(String sitemapName, @Nullable String title, @Null
615618 }
616619 bean .widgetId = widgetId ;
617620 bean .icon = itemUIRegistry .getCategory (widget );
618- bean .staticIcon = widget .getStaticIcon () != null || !widget .getIconRules ().getElements ().isEmpty ();
621+ bean .staticIcon = widget .getStaticIcon () != null
622+ || (widget .getIconRules () != null && !widget .getIconRules ().getElements ().isEmpty ());
619623 bean .labelcolor = convertItemValueColor (itemUIRegistry .getLabelColor (widget ), itemState );
620624 bean .valuecolor = convertItemValueColor (itemUIRegistry .getValueColor (widget ), itemState );
621625 bean .iconcolor = convertItemValueColor (itemUIRegistry .getIconColor (widget ), itemState );
@@ -643,7 +647,7 @@ private PageDTO createPageBean(String sitemapName, @Nullable String title, @Null
643647 isLeaf (children ), uri , locale , false , evenIfHidden );
644648 }
645649 }
646- if (widget instanceof Switch switchWidget ) {
650+ if (widget instanceof Switch switchWidget && switchWidget . getMappings () != null ) {
647651 for (Mapping mapping : switchWidget .getMappings ().getElements ()) {
648652 MappingDTO mappingBean = new MappingDTO ();
649653 mappingBean .command = mapping .getCmd ();
@@ -653,7 +657,7 @@ private PageDTO createPageBean(String sitemapName, @Nullable String title, @Null
653657 bean .mappings .add (mappingBean );
654658 }
655659 }
656- if (widget instanceof Selection selectionWidget ) {
660+ if (widget instanceof Selection selectionWidget && selectionWidget . getMappings () != null ) {
657661 for (Mapping mapping : selectionWidget .getMappings ().getElements ()) {
658662 MappingDTO mappingBean = new MappingDTO ();
659663 mappingBean .command = mapping .getCmd ();
@@ -731,7 +735,7 @@ private PageDTO createPageBean(String sitemapName, @Nullable String title, @Null
731735 if (widget instanceof Button buttonWidget ) {
732736 // Get the icon from the widget only
733737 if (widget .getIcon () == null && widget .getStaticIcon () == null
734- && widget .getIconRules (). getElements ().isEmpty ()) {
738+ && ( widget .getIconRules () == null || widget . getIconRules (). getElements ().isEmpty () )) {
735739 bean .icon = null ;
736740 bean .staticIcon = null ;
737741 }
@@ -872,36 +876,42 @@ private Set<GenericItem> getAllItems(List<Widget> widgets) {
872876 items .addAll (getAllItems (grid .getChildren ()));
873877 }
874878 // Consider items involved in any icon condition
875- items .addAll (getItemsInIconCond (widget .getIconRules (). getElements () ));
879+ items .addAll (getItemsInIconCond (widget .getIconRules ()));
876880 // Consider items involved in any visibility, labelcolor, valuecolor and iconcolor condition
877- items .addAll (getItemsInVisibilityCond (widget .getVisibility (). getElements () ));
878- items .addAll (getItemsInColorCond (widget .getLabelColor (). getElements () ));
879- items .addAll (getItemsInColorCond (widget .getValueColor (). getElements () ));
880- items .addAll (getItemsInColorCond (widget .getIconColor (). getElements () ));
881+ items .addAll (getItemsInVisibilityCond (widget .getVisibility ()));
882+ items .addAll (getItemsInColorCond (widget .getLabelColor ()));
883+ items .addAll (getItemsInColorCond (widget .getValueColor ()));
884+ items .addAll (getItemsInColorCond (widget .getIconColor ()));
881885 }
882886 return items ;
883887 }
884888
885- private Set <GenericItem > getItemsInVisibilityCond (EList < VisibilityRule > ruleList ) {
889+ private Set <GenericItem > getItemsInVisibilityCond (@ Nullable VisibilityRuleList ruleList ) {
886890 Set <GenericItem > items = new HashSet <>();
887- for (VisibilityRule rule : ruleList ) {
888- getItemsInConditions (rule .getConditions (), items );
891+ if (ruleList != null ) {
892+ for (VisibilityRule rule : ruleList .getElements ()) {
893+ getItemsInConditions (rule .getConditions (), items );
894+ }
889895 }
890896 return items ;
891897 }
892898
893- private Set <GenericItem > getItemsInColorCond (EList < ColorArray > colorList ) {
899+ private Set <GenericItem > getItemsInColorCond (@ Nullable ColorArrayList colorList ) {
894900 Set <GenericItem > items = new HashSet <>();
895- for (ColorArray rule : colorList ) {
896- getItemsInConditions (rule .getConditions (), items );
901+ if (colorList != null ) {
902+ for (ColorArray rule : colorList .getElements ()) {
903+ getItemsInConditions (rule .getConditions (), items );
904+ }
897905 }
898906 return items ;
899907 }
900908
901- private Set <GenericItem > getItemsInIconCond (EList < IconRule > ruleList ) {
909+ private Set <GenericItem > getItemsInIconCond (@ Nullable IconRuleList ruleList ) {
902910 Set <GenericItem > items = new HashSet <>();
903- for (IconRule rule : ruleList ) {
904- getItemsInConditions (rule .getConditions (), items );
911+ if (ruleList != null ) {
912+ for (IconRule rule : ruleList .getElements ()) {
913+ getItemsInConditions (rule .getConditions (), items );
914+ }
905915 }
906916 return items ;
907917 }
0 commit comments