@Override public ImmutableJsonPointer append(final JsonPointer subPointer) { checkSubPointer(subPointer); final ImmutableJsonPointer result; if (subPointer.isEmpty()) { result = this; } else { final List<JsonKey> newJsonKeys = new ArrayList<>(jsonKeyHierarchy); subPointer.forEach(newJsonKeys::add); result = newInstance(newJsonKeys); } return result; }
@Override public ImmutableJsonPointer append(final JsonPointer subPointer) { checkSubPointer(subPointer); final ImmutableJsonPointer result; if (subPointer.isEmpty()) { result = this; } else { final List<JsonKey> newJsonKeys = new ArrayList<>(jsonKeyHierarchy); subPointer.forEach(newJsonKeys::add); result = newInstance(newJsonKeys); } return result; }
/** * Returns a new JSON pointer instance. * * @param rootLevel the JSON key which is the root level of the JSON pointer to create. * @param subPointer the JSON keys which form sub levels to the root level as well as to each other. * @return a new JSON pointer consisting of hierarchical JSON keys. * @throws NullPointerException if any argument is {@code null}. */ static ImmutableJsonPointer of(final JsonKey rootLevel, final JsonPointer subPointer) { checkRootLevel(rootLevel); checkSubPointer(subPointer); final ImmutableJsonPointer result; final List<JsonKey> keyHierarchy = new ArrayList<>(1 + subPointer.getLevelCount()); keyHierarchy.add(rootLevel); subPointer.forEach(keyHierarchy::add); result = newInstance(keyHierarchy); return result; }
/** * Returns a new JSON pointer instance. * * @param rootLevel the JSON key which is the root level of the JSON pointer to create. * @param subPointer the JSON keys which form sub levels to the root level as well as to each other. * @return a new JSON pointer consisting of hierarchical JSON keys. * @throws NullPointerException if any argument is {@code null}. */ static ImmutableJsonPointer of(final JsonKey rootLevel, final JsonPointer subPointer) { checkRootLevel(rootLevel); checkSubPointer(subPointer); final ImmutableJsonPointer result; final List<JsonKey> keyHierarchy = new ArrayList<>(1 + subPointer.getLevelCount()); keyHierarchy.add(rootLevel); subPointer.forEach(keyHierarchy::add); result = newInstance(keyHierarchy); return result; }