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.annotations.Beta;
11 import com.google.common.annotations.VisibleForTesting;
12 import com.google.common.base.Verify;
13 import com.google.common.collect.ImmutableList;
14 import java.util.HashSet;
15 import java.util.List;
17 import org.opendaylight.yangtools.yang.model.api.Module;
18 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
19 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
20 import org.opendaylight.yangtools.yang.model.api.stmt.ModuleStatement;
21 import org.opendaylight.yangtools.yang.model.util.SimpleSchemaContext;
24 public final class EffectiveSchemaContext extends SimpleSchemaContext {
25 private final ImmutableList<DeclaredStatement<?>> rootDeclaredStatements;
26 private final ImmutableList<EffectiveStatement<?, ?>> rootEffectiveStatements;
28 private EffectiveSchemaContext(final Set<Module> modules, final List<DeclaredStatement<?>> rootDeclaredStatements,
29 final List<EffectiveStatement<?, ?>> rootEffectiveStatements) {
31 this.rootDeclaredStatements = ImmutableList.copyOf(rootDeclaredStatements);
32 this.rootEffectiveStatements = ImmutableList.copyOf(rootEffectiveStatements);
35 static EffectiveSchemaContext create(final List<DeclaredStatement<?>> rootDeclaredStatements,
36 final List<EffectiveStatement<?, ?>> rootEffectiveStatements) {
37 final Set<Module> modules = new HashSet<>();
38 for (EffectiveStatement<?, ?> stmt : rootEffectiveStatements) {
39 if (stmt.getDeclared() instanceof ModuleStatement) {
40 Verify.verify(stmt instanceof Module);
41 modules.add((Module) stmt);
45 return new EffectiveSchemaContext(modules, rootDeclaredStatements, rootEffectiveStatements);
49 public List<DeclaredStatement<?>> getRootDeclaredStatements() {
50 return rootDeclaredStatements;
54 public List<EffectiveStatement<?, ?>> getRootEffectiveStatements() {
55 return rootEffectiveStatements;