Commit 36eea625 authored by Szabolcs Gyurko's avatar Szabolcs Gyurko
Browse files

Added safety for null components

parent 204f0520
Pipeline #304 failed with stage
in 15 seconds
......@@ -27,6 +27,7 @@ package com.jeff_cms.jeff.web.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
......@@ -48,7 +49,7 @@ public class Page {
* @return the amalgamated set of headScripts from the components.
*/
public Set<String> getHeadScripts() {
return components.stream().map(Component::getHeadScripts).flatMap(Set::stream).collect(Collectors.toSet());
return components == null ? Collections.emptySet() : components.stream().map(Component::getHeadScripts).flatMap(Set::stream).collect(Collectors.toSet());
}
/**
......@@ -56,7 +57,7 @@ public class Page {
* @return the amalgamated set of scripts from the components.
*/
public Set<String> getScripts() {
return components.stream().map(Component::getScripts).flatMap(Set::stream).collect(Collectors.toSet());
return components == null ? Collections.emptySet() : components.stream().map(Component::getScripts).flatMap(Set::stream).collect(Collectors.toSet());
}
/**
......@@ -64,6 +65,6 @@ public class Page {
* @return the amalgamated set of styles from the components.
*/
public Set<String> getStyles() {
return components.stream().map(Component::getStyles).flatMap(Set::stream).collect(Collectors.toSet());
return components == null ? Collections.emptySet() : components.stream().map(Component::getStyles).flatMap(Set::stream).collect(Collectors.toSet());
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment