private static Collection<JsonPointer> flattenToJsonPointers(final String stringWithParentheses) { final int indexOfOpeningParenthesis = stringWithParentheses.indexOf(OPENING_PARENTHESIS); // the string before the first opening parenthesis final String commonRootKey = stringWithParentheses.substring(0, indexOfOpeningParenthesis); final JsonPointer commonRootPointer = JsonFactory.newPointer(commonRootKey); // the string within the opening and closing parenthesis // this string is (recursively) treated like a new field selector string (because technically it is) final String withoutParentheses = stringWithParentheses.substring(indexOfOpeningParenthesis + 1, stringWithParentheses.length() - 1); final Set<JsonPointer> jsonPointers = flattenToJsonPointers(splitAroundComma(withoutParentheses)); return jsonPointers.stream() // .map(commonRootPointer::append) // .collect(Collectors.toCollection(LinkedHashSet::new)); }
private static Set<JsonPointer> flattenToJsonPointers(final Iterable<String> rawJsonKeys) { final Set<JsonPointer> result = new LinkedHashSet<>(); for (final String rawJsonKey : rawJsonKeys) { if (isJsonSelectorFormat(rawJsonKey)) { result.addAll(flattenToJsonPointers(rawJsonKey)); } else { // slashes are already treated by the constructor of the JSON pointer result.add(JsonFactory.newPointer(rawJsonKey)); } } return result; }
private static Set<JsonPointer> flattenToJsonPointers(final Iterable<String> rawJsonKeys) { final Set<JsonPointer> result = new LinkedHashSet<>(); for (final String rawJsonKey : rawJsonKeys) { if (isJsonSelectorFormat(rawJsonKey)) { result.addAll(flattenToJsonPointers(rawJsonKey)); } else { // slashes are already treated by the constructor of the JSON pointer result.add(JsonFactory.newPointer(rawJsonKey)); } } return result; }
private static Collection<JsonPointer> flattenToJsonPointers(final String stringWithParentheses) { final int indexOfOpeningParenthesis = stringWithParentheses.indexOf(OPENING_PARENTHESIS); // the string before the first opening parenthesis final String commonRootKey = stringWithParentheses.substring(0, indexOfOpeningParenthesis); final JsonPointer commonRootPointer = JsonFactory.newPointer(commonRootKey); // the string within the opening and closing parenthesis // this string is (recursively) treated like a new field selector string (because technically it is) final String withoutParentheses = stringWithParentheses.substring(indexOfOpeningParenthesis + 1, stringWithParentheses.length() - 1); final Set<JsonPointer> jsonPointers = flattenToJsonPointers(splitAroundComma(withoutParentheses)); return jsonPointers.stream() // .map(commonRootPointer::append) // .collect(Collectors.toCollection(LinkedHashSet::new)); }
/** * Returns a new JSON field selector based on the parsed string which was given to this class' constructor. * * @return a new JSON field selector instance. * @throws IllegalStateException if the JSON field selector string could not be decoded as UTF-8. */ public JsonFieldSelector newJsonFieldSelector() { final List<String> rawJsonKeys = splitAroundComma(jsonFieldSelectorString); final Set<JsonPointer> jsonPointers = flattenToJsonPointers(rawJsonKeys); return ImmutableJsonFieldSelector.of(jsonPointers, jsonFieldSelectorString); } }
/** * Returns a new JSON field selector based on the parsed string which was given to this class' constructor. * * @return a new JSON field selector instance. * @throws IllegalStateException if the JSON field selector string could not be decoded as UTF-8. */ public JsonFieldSelector newJsonFieldSelector() { final List<String> rawJsonKeys = splitAroundComma(jsonFieldSelectorString); final Set<JsonPointer> jsonPointers = flattenToJsonPointers(rawJsonKeys); return ImmutableJsonFieldSelector.of(jsonPointers, jsonFieldSelectorString); } }