9e6bab8b2454d1c01e4ee78761b9d61f15724620
[yangtools.git] / yang / yang-parser-api / src / main / java / org / opendaylight / yangtools / yang / model / parser / api / YangParserFactory.java
1 /*
2  * Copyright (c) 2017 Pantheon Technologies, 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.yang.model.parser.api;
9
10 import com.google.common.annotations.Beta;
11 import java.util.Collection;
12 import org.eclipse.jdt.annotation.NonNull;
13 import org.opendaylight.yangtools.yang.model.repo.api.StatementParserMode;
14
15 /**
16  * Basic entry point into a YANG parser implementation. Implementations of this interface are expected to be
17  * thread-safe.
18  */
19 @Beta
20 public interface YangParserFactory {
21     /**
22      * Return enumeration of {@link StatementParserMode}s supported by this factory.
23      *
24      * @return Enumeration of supported schema source representations
25      */
26     Collection<StatementParserMode> supportedParserModes();
27
28     /**
29      * Create a {@link YangParser} instance operating with default {@link YangParserConfiguration}.
30      *
31      * @return A new {@link YangParser} instance
32      */
33     default @NonNull YangParser createParser() {
34         return createParser(YangParserConfiguration.DEFAULT);
35     }
36
37     /**
38      * Create a {@link YangParser} instance operating with specified {@link YangParserConfiguration}.
39      *
40      * @param configuration Requested parser configuration
41      * @return A new {@link YangParser} instance
42      * @throws NullPointerException if configuration is null
43      * @throws IllegalArgumentException if specified configuration is not supported
44      */
45     @NonNull YangParser createParser(YangParserConfiguration configuration);
46
47     /**
48      * Create a {@link YangParser} instance operating in specified import resolution mode.
49      *
50      * @param parserMode Requested parser mode, may not be null.
51      * @return A new {@link YangParser} instance
52      * @throws NullPointerException if parser mode is null
53      * @throws IllegalArgumentException if specified parser mode is not supported
54      * @deprecated Use {@link #createParser(YangParserConfiguration)} instead.
55      */
56     @Deprecated(forRemoval = true)
57     default @NonNull YangParser createParser(final StatementParserMode parserMode) {
58         return createParser(YangParserConfiguration.builder().parserMode(parserMode).build());
59     }
60 }