Add YangParserConfiguration
[yangtools.git] / yang / yang-parser-api / src / main / java / org / opendaylight / yangtools / yang / model / parser / api / YangParserFactory.java
index f97e40e97fff2b62be8423c0ba6986c9423a985e..78f827b0979aeba316a78c73a8bfbf021cebae62 100644 (file)
@@ -9,32 +9,41 @@ package org.opendaylight.yangtools.yang.model.parser.api;
 
 import com.google.common.annotations.Beta;
 import java.util.Collection;
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.model.repo.api.StatementParserMode;
 
 /**
  * Basic entry point into a YANG parser implementation. Implementations of this interface are expected to be
  * thread-safe.
- *
- * @author Robert Varga
  */
 @Beta
 public interface YangParserFactory {
     /**
      * Return enumeration of {@link StatementParserMode}s supported by this factory.
      *
-     * @return Enumeration of supported schema source representations.
+     * @return Enumeration of supported schema source representations
      */
     Collection<StatementParserMode> supportedParserModes();
 
     /**
-     * Create a {@link YangParser} instance operating in default import resolution mode.
+     * Create a {@link YangParser} instance operating with default {@link YangParserConfiguration}.
      *
      * @return A new {@link YangParser} instance
      */
-    default YangParser createParser() {
-        return createParser(StatementParserMode.DEFAULT_MODE);
+    default @NonNull YangParser createParser() {
+        return createParser(YangParserConfiguration.DEFAULT);
     }
 
+    /**
+     * Create a {@link YangParser} instance operating with specified {@link YangParserConfiguration}.
+     *
+     * @param configuration Requested parser configuration
+     * @return A new {@link YangParser} instance
+     * @throws NullPointerException if configuration is null
+     * @throws IllegalArgumentException if specified configuration is not supported
+     */
+    @NonNull YangParser createParser(YangParserConfiguration configuration);
+
     /**
      * Create a {@link YangParser} instance operating in specified import resolution mode.
      *
@@ -42,6 +51,10 @@ public interface YangParserFactory {
      * @return A new {@link YangParser} instance
      * @throws NullPointerException if parser mode is null
      * @throws IllegalArgumentException if specified parser mode is not supported
+     * @deprecated Use {@link #createParser(YangParserConfiguration)} instead.
      */
-    YangParser createParser(StatementParserMode parserMode);
+    @Deprecated(forRemoval = true)
+    default @NonNull YangParser createParser(final StatementParserMode parserMode) {
+        return createParser(YangParserConfiguration.builder().setParserMode(parserMode).build());
+    }
 }