Adds a constructor to allow the user to construct a ScreenBuilder directly from JSON.
@@ -4,6 +4,9 @@ import com.valkryst.VTerminal.component.Screen;
import lombok.Data;
import lombok.NonNull;
import org.json.simple.JSONObject;
+import org.json.simple.parser.ParseException;
+
+import java.io.FileNotFoundException;
@Data
public class ScreenBuilder extends ComponentBuilder<Screen> {
@@ -27,6 +30,26 @@ public class ScreenBuilder extends ComponentBuilder<Screen> {
super.height = height;
}
+ /**
+ * Constructs a ScreenBuilder from JSON.
+ *
+ * @see ComponentBuilder#loadFromJSON(String)
+ *
+ * @param jsonFilePath
+ * The path to the JSON file.
+ *
+ * @throws FileNotFoundException
+ * If the file does not exist, is a directory rather
+ * than a regular file, or for some other reason cannot
+ * be opened for reading.
+ *
+ * @throws ParseException
+ * If there's an error when parsing the JSON.
+ */
+ public ScreenBuilder(final @NonNull String jsonFilePath) throws FileNotFoundException, ParseException {
+ super.loadFromJSON(jsonFilePath);
+ }
+
@Override
public Screen build() {
checkState();
