import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.Spliterator;
throw new IllegalStateException("Utility class");
}
- static List<String> parseJsonToGelAllPnfCorrelationId(String json) {
- JsonElement je = new JsonParser().parse(json);
- JsonArray array = je.getAsJsonArray();
- List<String> list = new ArrayList<>();
- Spliterator<JsonElement> spliterator = array.spliterator();
- spliterator.forEachRemaining(jsonElement -> handleEscapedCharacters(jsonElement)
+ static List<String> parseJsonToGelAllPnfCorrelationId(List<String> list) {
+ if (list == null || list.isEmpty()) {
+ return Collections.emptyList();
+ }
+
+ List<String> newList = new ArrayList<>();
+ list.forEach(je -> handleEscapedCharacters(new JsonParser().parse(je))
.ifPresent(jsonObject -> getPnfCorrelationId(jsonObject)
- .ifPresent(pnfCorrelationId -> list.add(pnfCorrelationId))));
- return list;
+ .ifPresent(pnfCorrelationId -> newList.add(pnfCorrelationId))));
+ return newList;
}
private static Optional<JsonObject> handleEscapedCharacters(JsonElement jsonElement) {