Correct QName.compareTo()
[yangtools.git] / parser / 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 import org.opendaylight.yangtools.yang.parser.api.ImportResolutionMode;
15 import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration;
16
17 /**
18  * Basic entry point into a YANG parser implementation. Implementations of this interface are expected to be
19  * thread-safe.
20  *
21  * @deprecated Use {@link org.opendaylight.yangtools.yang.parser.api.YangParserFactory} instead.
22  */
23 @Beta
24 @Deprecated(since = "7.0.0", forRemoval = true)
25 public interface YangParserFactory {
26     /**
27      * Return enumeration of {@link StatementParserMode}s supported by this factory.
28      *
29      * @return Enumeration of supported schema source representations
30      */
31     Collection<StatementParserMode> supportedParserModes();
32
33     /**
34      * Create a {@link YangParser} instance operating with default {@link YangParserConfiguration}.
35      *
36      * @return A new {@link YangParser} instance
37      */
38     default @NonNull YangParser createParser() {
39         return createParser(YangParserConfiguration.DEFAULT);
40     }
41
42     /**
43      * Create a {@link YangParser} instance operating with specified {@link YangParserConfiguration}.
44      *
45      * @param configuration Requested parser configuration
46      * @return A new {@link YangParser} instance
47      * @throws NullPointerException if configuration is null
48      * @throws IllegalArgumentException if specified configuration is not supported
49      */
50     @NonNull YangParser createParser(YangParserConfiguration configuration);
51
52     /**
53      * Create a {@link YangParser} instance operating in specified import resolution mode.
54      *
55      * @param parserMode Requested parser mode, may not be null.
56      * @return A new {@link YangParser} instance
57      * @throws NullPointerException if parser mode is null
58      * @throws IllegalArgumentException if specified parser mode is not supported
59      * @deprecated Use {@link #createParser(YangParserConfiguration)} instead.
60      */
61     @Deprecated(forRemoval = true)
62     default @NonNull YangParser createParser(final StatementParserMode parserMode) {
63         final ImportResolutionMode importMode;
64         switch (parserMode) {
65             case DEFAULT_MODE:
66                 importMode = ImportResolutionMode.DEFAULT;
67                 break;
68             case SEMVER_MODE:
69                 importMode = ImportResolutionMode.OPENCONFIG_SEMVER;
70                 break;
71             default:
72                 throw new IllegalArgumentException("Unsupported mode " + parserMode);
73         }
74
75         return createParser(YangParserConfiguration.builder().importResolutionMode(importMode).build());
76     }
77 }