Skip to content

Commit

Permalink
reduce complexity of methods in GeoCodeBasic
Browse files Browse the repository at this point in the history
  • Loading branch information
dickschoeller committed May 17, 2020
1 parent dfa1bec commit c085e04
Showing 1 changed file with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,11 @@ public final String toString() {
names.add(name);
}

appendNamesToBuilder(builder, names);
return builder.toString();
}

private void appendNamesToBuilder(final StringBuilder builder, final SortedSet<String> names) {
for (final String name : names) {
final GeoDocument geoDocument = getDocument(name);
builder.append(geoDocument.getName());
Expand All @@ -282,16 +287,19 @@ public final String toString() {
builder.append(geoDocument.getModernName());
}
builder.append("|");
if (geoDocument.getResult() == null) {
builder.append("NOT FOUND");
builder.append("|");
} else {
builder.append(geoDocument.getResult().geometry.location);
builder.append("|");
builder.append(geoDocument.getResult().formattedAddress);
}
appendResultToBuilder(builder, geoDocument);
builder.append("\n");
}
return builder.toString();
}

private void appendResultToBuilder(final StringBuilder builder, final GeoDocument geoDocument) {
if (geoDocument.getResult() == null) {
builder.append("NOT FOUND");
builder.append("|");
} else {
builder.append(geoDocument.getResult().geometry.location);
builder.append("|");
builder.append(geoDocument.getResult().formattedAddress);
}
}
}

0 comments on commit c085e04

Please sign in to comment.