Promote SchemaSourceRepresentation
[yangtools.git] / model / yang-model-api / src / main / java / org / opendaylight / yangtools / yang / model / api / source / SourceRepresentation.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. 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.yang.model.api.source;
9
10 import org.eclipse.jdt.annotation.NonNull;
11 import org.eclipse.jdt.annotation.Nullable;
12 import org.opendaylight.yangtools.concepts.Immutable;
13
14 /**
15  * Common interface for schema source representations. A schema source is an atomic piece of the overall schema context.
16  * In YANG terms, a schema source is semantically equivalent to a single YANG text file, be it a module or a submodule.
17  *
18  * <p>
19  * A schema source can exist in various forms, which we call representations. Again, in YANG terms, each representation
20  * is semantically equivalent, but from implementation perspective certain operations on a schema source may require it
21  * to be first transformed into a particular representation before they can be applied. Such transformations are
22  * affected via instances of SchemaSourceTransformation.
23  *
24  * <p>
25  * Typical examples of a schema source representation include:
26  * <ul>
27  *   <li>a {@link java.lang.String} - textual representation of source code</li>
28  *   <li>a {@link java.io.InputStream} - input stream containing source code</li>
29  *   <li>a {@link com.google.common.io.ByteSource} - source for input streams containing source code</li>
30  *   <li>Parsed abstract syntax tree (AST), which is the result of a syntactic parser</li>
31  * </ul>
32  *
33  * <p>
34  * Implementations of this interface expected to comply with the {@link Immutable} contract.
35  */
36 public sealed interface SourceRepresentation extends Immutable
37         permits YangSourceRepresentation, YinSourceRepresentation {
38     /**
39      * The {@link SourceIdentifier} of this source.
40      *
41      * @return {@link SourceIdentifier} of this source
42      */
43     @NonNull SourceIdentifier sourceId();
44
45     /**
46      * Return the concrete representation type.
47      *
48      * @return The type of representation.
49      */
50     @NonNull Class<? extends SourceRepresentation> getType();
51
52     /**
53      * Return the symbolic name, if available. This name has no semantic meaning beyond being useful for debugging
54      * by humans.
55      *
56      * @return Symbolic name, if available
57      */
58     @Nullable String symbolicName();
59 }