Преглед на файлове

Fix NPE w/ Ingredient handling.

Sam Jaffe преди 5 години
родител
ревизия
6fc4579b65
променени са 2 файла, в които са добавени 5 реда и са изтрити 1 реда
  1. 4 0
      src/main/lombok/org/leumasjaffe/recipe/model/Ingredient.java
  2. 1 1
      src/main/lombok/org/leumasjaffe/recipe/model/Preparation.java

+ 4 - 0
src/main/lombok/org/leumasjaffe/recipe/model/Ingredient.java

@@ -13,6 +13,10 @@ public class Ingredient extends Observable.Instance {
 	String preparation = "";
 	Amount amount;
 	
+	boolean hasPreparation() {
+		return preparation != null && !preparation.isEmpty();
+	}
+	
 	Ingredient plus(final Ingredient rhs) {
 		if (!name.equals(rhs.name)) {
 			throw new IllegalArgumentException("Combining ingredients of differing types");

+ 1 - 1
src/main/lombok/org/leumasjaffe/recipe/model/Preparation.java

@@ -19,7 +19,7 @@ public class Preparation implements RecipeComponent {
 	
 	@JsonIgnore
 	public List<Ingredient> getIngredients() {
-		return producer.get().stream().filter(i -> !i.getPreparation().isEmpty())
+		return producer.get().stream().filter(Ingredient::hasPreparation)
 				.collect(Collectors.toList());
 	}
 }