浏览代码

Properly visualize rests.

Sam Jaffe 5 年之前
父节点
当前提交
061791c886

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

@@ -1,11 +1,19 @@
 package org.leumasjaffe.recipe.model;
 
+import lombok.AccessLevel;
+import lombok.AllArgsConstructor;
 import lombok.Data;
+import lombok.Getter;
+import lombok.experimental.FieldDefaults;
 
 @Data
 public class Rest {
+	@AllArgsConstructor @Getter @FieldDefaults(level=AccessLevel.PRIVATE, makeFinal=true)
 	public enum Where {
-		FREEZER, REFRIGERATOR, ROOM_TEMPERATURE, WARM_PLACE
+		FREEZER("in the freezer"), REFRIGERATOR("in the refrigerator"),
+		ROOM_TEMPERATURE("at room temperature"), WARM_PLACE("in a warm place");
+		
+		String humanReadable;
 	}
 	
 	Where where;

+ 1 - 1
src/main/lombok/org/leumasjaffe/recipe/view/RestPanel.java

@@ -26,7 +26,7 @@ public class RestPanel extends JPanel {
 		gbc_lblRest.gridy = 0;
 		add(lblRest, gbc_lblRest);
 		
-		JLabel lblLocation = new JLabel(rest.getWhere().toString());
+		JLabel lblLocation = new JLabel(rest.getWhere().getHumanReadable());
 		GridBagConstraints gbc_lblLocation = new GridBagConstraints();
 		gbc_lblLocation.insets = new Insets(0, 0, 0, 5);
 		gbc_lblLocation.gridx = 1;

+ 10 - 1
src/test/resources/example.json

@@ -56,7 +56,16 @@
 	            },
           		"instruction": "Sauté the onions until soft and translucent, stirring to prevent burning"
           	}
-          ]
+          ],
+          "rest": {
+          	"where": "ROOM_TEMPERATURE",
+            "duration": {
+              "displayAs": "SECONDS",
+              "approximate": false,
+              "minSeconds": 30,
+              "maxSeconds": 30
+            }
+          }
         }
       ]
     }