private static List<Source> getSources(final JsonObject jsonObject, final ConnectionType type) { final Optional<JsonArray> sourcesArray = jsonObject.getValue(JsonFields.SOURCES); if (sourcesArray.isPresent()) { final JsonArray values = sourcesArray.get(); return IntStream.range(0, values.getSize()) .mapToObj(index -> values.get(index) .filter(JsonValue::isObject) .map(JsonValue::asObject) .map(valueAsObject -> ConnectivityModelFactory.sourceFromJson(valueAsObject, index, type))) .filter(Optional::isPresent) .map(Optional::get) .collect(Collectors.toList()); } else { return Collections.emptyList(); } }
private static List<Source> getSources(final JsonObject jsonObject, final ConnectionType type) { final Optional<JsonArray> sourcesArray = jsonObject.getValue(JsonFields.SOURCES); if (sourcesArray.isPresent()) { final JsonArray values = sourcesArray.get(); return IntStream.range(0, values.getSize()) .mapToObj(index -> values.get(index) .filter(JsonValue::isObject) .map(JsonValue::asObject) .map(valueAsObject -> ConnectivityModelFactory.sourceFromJson(valueAsObject, index, type))) .filter(Optional::isPresent) .map(Optional::get) .collect(Collectors.toList()); } else { return Collections.emptyList(); } }