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