Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import edu.suffolk.litlab.efsp.utils.FilingError;
import edu.suffolk.litlab.efsp.utils.InfoCollector;
import edu.suffolk.litlab.efsp.utils.InterviewVariable;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import org.slf4j.Logger;
Expand All @@ -32,18 +31,16 @@ public static Optional<Address> fromNode(
throw err;
}

List<InterviewVariable> potentiallyReq = new ArrayList<InterviewVariable>();
boolean oneMissing = false;
for (String member : List.of("address", "unit", "city", "state", "zip")) {
if (!node.has(member)) {
if (!node.has(member) || (node.has(member) && node.get(member).isNull())) {
oneMissing = true;
potentiallyReq.add(collector.requestVar(member, "part of the address", "text"));
continue;
break;
}
if (node.has(member) && !node.get(member).isTextual()) {
FilingError err =
FilingError.malformedInterview(
"Refusing to parse an address where the "
"Refusing to parse address where the "
+ member
+ " isn't text: "
+ node.toPrettyString());
Expand All @@ -54,11 +51,6 @@ public static Optional<Address> fromNode(
if (oneMissing) {
return Optional.empty();
}
if (!potentiallyReq.isEmpty()) {
for (InterviewVariable memberVar : potentiallyReq) {
collector.addRequired(memberVar);
}
}
String address = (node.has("address")) ? node.get("address").asText("") : "";
String unit = (node.has("unit")) ? node.get("unit").asText("") : "";
String city = (node.has("city")) ? node.get("city").asText("") : "";
Expand Down
Loading