2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.yangtools.yang.parser.stmt.reactor;
10 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.EffectiveSchemaContext;
12 import com.google.common.collect.ImmutableMap;
13 import java.util.EnumMap;
15 import org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase;
16 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
17 import org.opendaylight.yangtools.yang.parser.spi.meta.StatementSupportBundle;
18 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
19 import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
21 public class CrossSourceStatementReactor {
23 private final Map<ModelProcessingPhase,StatementSupportBundle> supportedTerminology;
25 CrossSourceStatementReactor(Map<ModelProcessingPhase, StatementSupportBundle> supportedTerminology) {
26 this.supportedTerminology = ImmutableMap.copyOf(supportedTerminology);
29 public static final Builder builder() {
33 public final BuildAction newBuild() {
34 return new BuildAction();
37 public static class Builder implements org.opendaylight.yangtools.concepts.Builder<CrossSourceStatementReactor>{
39 final Map<ModelProcessingPhase,StatementSupportBundle> bundles = new EnumMap<>(ModelProcessingPhase.class);
41 public Builder setBundle(ModelProcessingPhase phase,StatementSupportBundle bundle) {
42 bundles.put(phase, bundle);
47 public CrossSourceStatementReactor build() {
48 return new CrossSourceStatementReactor(bundles);
53 public class BuildAction {
55 private final BuildGlobalContext context;
57 public BuildAction() {
58 this.context = new BuildGlobalContext(supportedTerminology);
61 public void addSource(StatementStreamSource source) {
62 context.addSource(source);
65 public EffectiveModelContext build() throws SourceException, ReactorException {
66 return context.build();
69 public EffectiveSchemaContext buildEffective() throws SourceException, ReactorException {
70 return context.buildEffective();