Retrofit mount-point awareness into yang-data-util
[yangtools.git] / yang / rfc8528-data-api / src / main / java / org / opendaylight / yangtools / rfc8528 / data / api / MountPointStreamWriter.java
1 /*
2  * Copyright (c) 2019 PANTHEON.tech s.r.o. and others. All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.yangtools.rfc8528.data.api;
9
10 import com.google.common.annotations.Beta;
11 import java.util.Optional;
12 import org.eclipse.jdt.annotation.NonNull;
13 import org.opendaylight.yangtools.rfc8528.model.api.MountPointSchemaResolver;
14 import org.opendaylight.yangtools.yang.common.QName;
15 import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter;
16 import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriterExtension;
17 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
18
19 /**
20  * A {@link NormalizedNodeStreamWriterExtension} exposed by stream writers which can handle mount point data, notably
21  * providing the facilities to resolve a mount point schema and normalize mount point contents into a normalized
22  * structure.
23  */
24 @Beta
25 public interface MountPointStreamWriter extends NormalizedNodeStreamWriterExtension {
26     /**
27      * Attempt to acquire a {@link MountPointSchemaResolver} to resolve schemas for the purposes of interpreting this
28      * mount point. An empty result indicates the mount point is not attached.
29      *
30      * @param label Mount point label, as defined via the use of {@code mount-point} statement
31      * @return An optional handler for mount point data
32      * @throws NullPointerException if label is null
33      */
34     Optional<MountPointSchemaResolver> findMountPoint(@NonNull QName label);
35
36     /**
37      * Start a new mount point with a specific root context.
38      *
39      * @param label Mount point label
40      * @param mountContext SchemaContext associated with the context
41      * @return A new NormalizedNodeStreamWriter, or empty if the mount point data should be ignored
42      */
43     Optional<NormalizedNodeStreamWriter> startMountPoint(@NonNull QName label, @NonNull SchemaContext mountContext);
44 }