/** * Create a new writer with the specified context and rooted in the specified schema path. * * @param context Associated {@link SchemaContext} * @param path schema path * @return A new {@link NormalizedNodeStreamWriter} */ public static SchemaTracker create(final SchemaContext context, final SchemaPath path) { return new SchemaTracker(context, path); }
/** * Create a new writer with the specified context as its root. * * @param context Associated {@link SchemaContext}. * @return A new {@link NormalizedNodeStreamWriter} */ // FIXME: 3.0.0: remove this method public static @NonNull SchemaTracker create(final SchemaContext context) { return new SchemaTracker(context); }
/** * Create a new writer with the specified node as its root. * * @param root Root node * @return A new {@link NormalizedNodeStreamWriter} */ public static @NonNull SchemaTracker create(final DataNodeContainer root) { return new SchemaTracker(root); }
/** * Create a new writer with the specified context and rooted in the specified schema path. * * @param context Associated {@link SchemaContext} * @param path schema path * @return A new {@link NormalizedNodeStreamWriter} */ public static @NonNull SchemaTracker create(final SchemaContext context, final SchemaPath path) { final Collection<SchemaNode> schemaNodes = SchemaUtils.findParentSchemaNodesOnPath(context, path); checkArgument(!schemaNodes.isEmpty(), "Unable to find schema node for supplied schema path: %s", path); if (schemaNodes.size() > 1) { LOG.warn("More possible schema nodes {} for supplied schema path {}", schemaNodes, path); } final Optional<DataNodeContainer> current = schemaNodes.stream() .filter(node -> node instanceof DataNodeContainer).map(DataNodeContainer.class::cast) .findFirst(); checkArgument(current.isPresent(), "Schema path must point to container or list or an rpc input/output. Supplied path %s pointed to: %s", path, current); return new SchemaTracker(current.get()); }