/** * Creates a path using the provided JsonPath structure. * * @param jsonPath JsonPath structure to be parsed * @return String representing structure provided in the input */ public static String buildPath(JsonPath jsonPath) { List<String> urlParts = new LinkedList<>(); JsonPath currentJsonPath = jsonPath; String pathPart; do { if (currentJsonPath instanceof RelationshipsPath) { pathPart = RELATIONSHIP_MARK + SEPARATOR + currentJsonPath.getElementName(); } else if (currentJsonPath instanceof FieldPath) { pathPart = currentJsonPath.getElementName(); } else { pathPart = currentJsonPath.getElementName(); if (currentJsonPath.getIds() != null) { pathPart += SEPARATOR + mergeIds(currentJsonPath.getIds()); } } urlParts.add(pathPart); currentJsonPath = currentJsonPath.getParentResource(); } while (currentJsonPath != null); Collections.reverse(urlParts); return SEPARATOR + StringUtils.join(SEPARATOR, urlParts) + SEPARATOR; }