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 com.google.common.collect.ImmutableMap;
11 import java.util.EnumMap;
13 import org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase;
14 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
15 import org.opendaylight.yangtools.yang.parser.spi.meta.StatementSupportBundle;
16 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
17 import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
19 public class CrossSourceStatementReactor {
21 private final Map<ModelProcessingPhase,StatementSupportBundle> supportedTerminology;
23 CrossSourceStatementReactor(Map<ModelProcessingPhase, StatementSupportBundle> supportedTerminology) {
24 this.supportedTerminology = ImmutableMap.copyOf(supportedTerminology);
27 public static final Builder builder() {
31 public final BuildAction newBuild() {
32 return new BuildAction();
35 public static class Builder implements org.opendaylight.yangtools.concepts.Builder<CrossSourceStatementReactor>{
37 final Map<ModelProcessingPhase,StatementSupportBundle> bundles = new EnumMap<>(ModelProcessingPhase.class);
39 public Builder setBundle(ModelProcessingPhase phase,StatementSupportBundle bundle) {
40 bundles.put(phase, bundle);
45 public CrossSourceStatementReactor build() {
46 return new CrossSourceStatementReactor(bundles);
51 public class BuildAction {
53 private final BuildGlobalContext context;
55 public BuildAction() {
56 this.context = new BuildGlobalContext(supportedTerminology);
59 public void addSource(StatementStreamSource source) {
60 context.addSource(source);
63 public EffectiveModelContext build() throws SourceException, ReactorException {
64 return context.build();