YANGTOOLS-706: Refactor YangInferencePipeline
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / impl / DefaultReactors.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.parser.impl;
9
10 import com.google.common.annotations.Beta;
11 import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
12 import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor.Builder;
13 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
14
15 /**
16  * Utility class for instantiating default-configured {@link CrossSourceStatementReactor}s.
17  *
18  * @author Robert Varga
19  */
20 @Beta
21 public final class DefaultReactors {
22     private static final CrossSourceStatementReactor DEFAULT_REACTOR = createDefaultReactorBuilder().build();
23
24     private DefaultReactors() {
25         throw new UnsupportedOperationException();
26     }
27
28     /**
29      * Get a shared default-configured reactor instance. This instance is configured to handle both RFC6020 and RFC7950,
30      * as well as RFC8040's yang-data extension.
31      *
32      * @return a shared default-configured reactor instance.
33      */
34     public static CrossSourceStatementReactor defaultReactor() {
35         return DEFAULT_REACTOR;
36     }
37
38     /**
39      * Return a baseline CrossSourceStatementReactor {@link Builder}. The builder is initialized to the equivalent
40      * of the reactor returned via {@link #defaultReactor()}, but can be further customized before use.
41      *
42      * @return A populated CrossSourceStatementReactor builder.
43      */
44     public static Builder createDefaultReactorBuilder() {
45         // FIXME: customize with extensions
46         return YangInferencePipeline.newReactorBuilder();
47     }
48 }